@stackgenhq/backstage-plugin-stackgen-backend 0.3.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +485 -0
- package/config.d.ts +39 -0
- package/dist/actions/core/assign_project_members_action.cjs.js +227 -0
- package/dist/actions/core/assign_project_members_action.cjs.js.map +1 -0
- package/dist/actions/core/create_appstack_action.cjs.js +953 -0
- package/dist/actions/core/create_appstack_action.cjs.js.map +1 -0
- package/dist/actions/core/create_project_action.cjs.js +243 -0
- package/dist/actions/core/create_project_action.cjs.js.map +1 -0
- package/dist/actions/core/download_iac_action.cjs.js +133 -0
- package/dist/actions/core/download_iac_action.cjs.js.map +1 -0
- package/dist/actions/core/set_environment_variable_values_action.cjs.js +121 -0
- package/dist/actions/core/set_environment_variable_values_action.cjs.js.map +1 -0
- package/dist/actions/core/set_state_backend_action.cjs.js +174 -0
- package/dist/actions/core/set_state_backend_action.cjs.js.map +1 -0
- package/dist/actions/exporter/export_iac_to_git_action.cjs.js +290 -0
- package/dist/actions/exporter/export_iac_to_git_action.cjs.js.map +1 -0
- package/dist/actions/exporter/list_vault_secrets_action.cjs.js +39 -0
- package/dist/actions/exporter/list_vault_secrets_action.cjs.js.map +1 -0
- package/dist/config/constants.cjs.js +23 -0
- package/dist/config/constants.cjs.js.map +1 -0
- package/dist/exporter/exportOverrides.cjs.js +27 -0
- package/dist/exporter/exportOverrides.cjs.js.map +1 -0
- package/dist/exporter/gitExporterConfigHttp.cjs.js +105 -0
- package/dist/exporter/gitExporterConfigHttp.cjs.js.map +1 -0
- package/dist/exporter/http.cjs.js +14 -0
- package/dist/exporter/http.cjs.js.map +1 -0
- package/dist/exporter/paths.cjs.js +25 -0
- package/dist/exporter/paths.cjs.js.map +1 -0
- package/dist/exporter/projectGitExporterTemplate.cjs.js +62 -0
- package/dist/exporter/projectGitExporterTemplate.cjs.js.map +1 -0
- package/dist/exporter/topologyResolve.cjs.js +71 -0
- package/dist/exporter/topologyResolve.cjs.js.map +1 -0
- package/dist/index.cjs.js +31 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +224 -0
- package/dist/lib/extractArchive.cjs.js +62 -0
- package/dist/lib/extractArchive.cjs.js.map +1 -0
- package/dist/modules/stackgenExporterScaffolderModule.cjs.js +29 -0
- package/dist/modules/stackgenExporterScaffolderModule.cjs.js.map +1 -0
- package/dist/modules/stackgenUiProxiesModule.cjs.js +366 -0
- package/dist/modules/stackgenUiProxiesModule.cjs.js.map +1 -0
- package/dist/plugin/plugin.cjs.js +136 -0
- package/dist/plugin/plugin.cjs.js.map +1 -0
- package/dist/plugin/router.cjs.js +341 -0
- package/dist/plugin/router.cjs.js.map +1 -0
- package/dist/services/MappingsService/mappingsService.cjs.js +149 -0
- package/dist/services/MappingsService/mappingsService.cjs.js.map +1 -0
- package/dist/services/StackgenService/stackgenService.cjs.js +267 -0
- package/dist/services/StackgenService/stackgenService.cjs.js.map +1 -0
- package/dist/utils/api-objects.cjs.js +205 -0
- package/dist/utils/api-objects.cjs.js.map +1 -0
- package/dist/vendor/stackgen-api-client/index.cjs.js +47681 -0
- package/dist/vendor/stackgen-api-client/index.cjs.js.map +1 -0
- package/migrations/20250131055302_init.js +24 -0
- package/migrations/20250305123456_alter_type_associations.js +23 -0
- package/package.json +86 -0
- package/templates/appstack-configure-environment.yaml +81 -0
- package/templates/appstack-from-template.yaml +76 -0
- package/templates/appstack-with-modules.yaml +69 -0
- package/templates/appstack-with-resources.yaml +81 -0
- package/templates/export-iac.yaml +97 -0
- package/templates/full-infra-setup.yaml +156 -0
- package/templates/git_export_exporter_multi_scm.yaml +123 -0
- package/templates/project-advanced.yaml +77 -0
- package/templates/project-basic.yaml +39 -0
- package/templates/project-with-members.yaml +86 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param { import("knex").Knex } knex
|
|
3
|
+
* @returns { Promise<void> }
|
|
4
|
+
*/
|
|
5
|
+
exports.up = function up(knex) {
|
|
6
|
+
return knex.schema.createTable("mappings", (table) => {
|
|
7
|
+
table.string("id").primary();
|
|
8
|
+
table.string("name").notNullable();
|
|
9
|
+
table.string("type_associations").notNullable();
|
|
10
|
+
table.string("created_by").notNullable();
|
|
11
|
+
table.dateTime("created_at").notNullable();
|
|
12
|
+
table.dateTime("updated_at").notNullable();
|
|
13
|
+
|
|
14
|
+
table.index("name");
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param { import("knex").Knex } knex
|
|
20
|
+
* @returns { Promise<void> }
|
|
21
|
+
*/
|
|
22
|
+
exports.down = function down(knex) {
|
|
23
|
+
return knex.schema.dropTable("mappings");
|
|
24
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param { import("knex").Knex } knex
|
|
3
|
+
* @returns { Promise<void> }
|
|
4
|
+
*/
|
|
5
|
+
exports.up = async function up(knex) {
|
|
6
|
+
await knex.schema.alterTable("mappings", (table) => {
|
|
7
|
+
table.json("type_associations").notNullable().alter();
|
|
8
|
+
table.string("cloud_provider").notNullable().defaultTo("aws");
|
|
9
|
+
table.unique("name");
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param { import("knex").Knex } knex
|
|
15
|
+
* @returns { Promise<void> }
|
|
16
|
+
*/
|
|
17
|
+
exports.down = async function down(knex) {
|
|
18
|
+
await knex.schema.alterTable("mappings", (table) => {
|
|
19
|
+
table.string("type_associations", 255).notNullable().alter();
|
|
20
|
+
table.dropColumn("cloud_provider");
|
|
21
|
+
table.dropUnique("name");
|
|
22
|
+
});
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackgenhq/backstage-plugin-stackgen-backend",
|
|
3
|
+
"version": "0.3.6-beta.1",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"description": "StackGen Backstage backend plugin — scaffolder actions, UI proxies, templates",
|
|
8
|
+
"author": "StackGen",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/appcd-dev/backstage-plugin-stackgen-backend.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/appcd-dev/backstage-plugin-stackgen-backend/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/appcd-dev/backstage-plugin-stackgen-backend#readme",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"main": "dist/index.cjs.js",
|
|
20
|
+
"types": "dist/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"backstage": {
|
|
23
|
+
"role": "backend-plugin",
|
|
24
|
+
"pluginId": "stackgen",
|
|
25
|
+
"pluginPackages": [
|
|
26
|
+
"@stackgenhq/backstage-plugin-stackgen-backend"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"start": "yarn build:vendor && backstage-cli package start",
|
|
31
|
+
"build:vendor": "tsup && dts-bundle-generator --external-inlines=@appcd-dev/stackgen-api-client --export-referenced-types=false --no-check --no-banner -o vendor/stackgen-api-client/index.d.ts scripts/stackgen-api-client-entry.ts",
|
|
32
|
+
"build": "yarn build:vendor && backstage-cli package build",
|
|
33
|
+
"lint": "backstage-cli package lint",
|
|
34
|
+
"test": "yarn build:vendor && backstage-cli package test --watchAll=false",
|
|
35
|
+
"clean": "backstage-cli package clean",
|
|
36
|
+
"prepack": "yarn build:vendor && backstage-cli package prepack",
|
|
37
|
+
"postpack": "backstage-cli package postpack"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@backstage/backend-plugin-api": "^1.7.0",
|
|
41
|
+
"@backstage/catalog-model": "^1.7.6",
|
|
42
|
+
"@backstage/config": "^1.3.2",
|
|
43
|
+
"@backstage/errors": "^1.2.7",
|
|
44
|
+
"@backstage/plugin-scaffolder-node": "^0.12.5",
|
|
45
|
+
"@xhmikosr/decompress": "^11.1.3",
|
|
46
|
+
"express": "^4.17.1",
|
|
47
|
+
"express-promise-router": "^4.1.0",
|
|
48
|
+
"knex": "^3.1.0",
|
|
49
|
+
"zod": "^3.25.76"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@appcd-dev/stackgen-api-client": "0.1.78",
|
|
53
|
+
"@backstage/backend-defaults": "^0.7.0",
|
|
54
|
+
"@backstage/backend-test-utils": "^1.2.1",
|
|
55
|
+
"@backstage/cli": "^0.29.5",
|
|
56
|
+
"@backstage/plugin-catalog-node": "^1.15.1",
|
|
57
|
+
"@types/express": "^4.17.6",
|
|
58
|
+
"@types/jest": "^30.0.0",
|
|
59
|
+
"@types/supertest": "^2.0.12",
|
|
60
|
+
"dts-bundle-generator": "9.5.1",
|
|
61
|
+
"eslint-plugin-jest": "^29.12.2",
|
|
62
|
+
"supertest": "^7.2.2",
|
|
63
|
+
"tsup": "^8.5.0",
|
|
64
|
+
"typescript": "^5.8.3"
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"dist",
|
|
68
|
+
"migrations/**/*.{js,d.ts}",
|
|
69
|
+
"./config.d.ts",
|
|
70
|
+
"templates/**/*.yaml"
|
|
71
|
+
],
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=20"
|
|
74
|
+
},
|
|
75
|
+
"packageManager": "yarn@4.6.0",
|
|
76
|
+
"resolutions": {
|
|
77
|
+
"dts-bundle-generator/typescript": "5.8.3"
|
|
78
|
+
},
|
|
79
|
+
"typesVersions": {
|
|
80
|
+
"*": {
|
|
81
|
+
"index": [
|
|
82
|
+
"dist/index.d.ts"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Configure AppStack Environment
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Applies Terraform variable values onto an existing environment profile
|
|
5
|
+
# (consumption — does not create environments or state backends).
|
|
6
|
+
# Demonstrates TeamSelect + AppStackSelect + EnvironmentSelect + VariableSelect
|
|
7
|
+
# + stackGen:setEnvironmentVariableValues.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
apiVersion: scaffolder.backstage.io/v1beta3
|
|
10
|
+
kind: Template
|
|
11
|
+
metadata:
|
|
12
|
+
name: stackgen-appstack-configure-environment
|
|
13
|
+
title: Configure AppStack Environment
|
|
14
|
+
description: Set Terraform variable values on an existing AppStack environment
|
|
15
|
+
tags:
|
|
16
|
+
- stackgen
|
|
17
|
+
- environment
|
|
18
|
+
- variables
|
|
19
|
+
spec:
|
|
20
|
+
owner: user:guest
|
|
21
|
+
type: service
|
|
22
|
+
parameters:
|
|
23
|
+
- title: Target AppStack
|
|
24
|
+
required:
|
|
25
|
+
- teamId
|
|
26
|
+
- appstackName
|
|
27
|
+
- environmentId
|
|
28
|
+
properties:
|
|
29
|
+
teamId:
|
|
30
|
+
title: Team / Project
|
|
31
|
+
type: string
|
|
32
|
+
ui:field: TeamSelect
|
|
33
|
+
appstackName:
|
|
34
|
+
title: AppStack
|
|
35
|
+
type: string
|
|
36
|
+
ui:field: AppStackSelect
|
|
37
|
+
ui:options:
|
|
38
|
+
teamId: teamId
|
|
39
|
+
environmentId:
|
|
40
|
+
title: Environment
|
|
41
|
+
type: string
|
|
42
|
+
description: Existing environment to configure
|
|
43
|
+
ui:field: EnvironmentSelect
|
|
44
|
+
ui:options:
|
|
45
|
+
teamId: teamId
|
|
46
|
+
appstackName: appstackName
|
|
47
|
+
|
|
48
|
+
- title: Variable Values
|
|
49
|
+
properties:
|
|
50
|
+
variableValues:
|
|
51
|
+
title: Variable Values
|
|
52
|
+
type: array
|
|
53
|
+
description: Pick TF variables and set values for the selected environment
|
|
54
|
+
ui:field: VariableSelect
|
|
55
|
+
ui:options:
|
|
56
|
+
teamId: teamId
|
|
57
|
+
appstackName: appstackName
|
|
58
|
+
items:
|
|
59
|
+
type: object
|
|
60
|
+
properties:
|
|
61
|
+
name:
|
|
62
|
+
type: string
|
|
63
|
+
value:
|
|
64
|
+
type: string
|
|
65
|
+
|
|
66
|
+
steps:
|
|
67
|
+
- id: setEnvVars
|
|
68
|
+
name: Apply Variable Values to Environment
|
|
69
|
+
action: stackGen:setEnvironmentVariableValues
|
|
70
|
+
input:
|
|
71
|
+
teamId: ${{ parameters.teamId }}
|
|
72
|
+
appstackName: ${{ parameters.appstackName }}
|
|
73
|
+
environmentId: ${{ parameters.environmentId }}
|
|
74
|
+
variableValues: ${{ parameters.variableValues }}
|
|
75
|
+
|
|
76
|
+
output:
|
|
77
|
+
text:
|
|
78
|
+
- title: Environment ID
|
|
79
|
+
content: ${{ steps.setEnvVars.output.environmentId }}
|
|
80
|
+
- title: Updated variables
|
|
81
|
+
content: ${{ steps.setEnvVars.output.updatedVariablesText }}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Create AppStack from Template
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Clones topology from an existing StackGen template AppStack onto a new
|
|
5
|
+
# AppStack in a target team/project (stackGen:createAppStack + templateAppstackId).
|
|
6
|
+
#
|
|
7
|
+
# Prerequisites:
|
|
8
|
+
# - STACKGEN_BASE_URL / STACKGEN_API_TOKEN configured
|
|
9
|
+
# - A template AppStack UUID you can read (set stackGen.orgId if it lives
|
|
10
|
+
# in another org than the destination team)
|
|
11
|
+
# =============================================================================
|
|
12
|
+
apiVersion: scaffolder.backstage.io/v1beta3
|
|
13
|
+
kind: Template
|
|
14
|
+
metadata:
|
|
15
|
+
name: stackgen-appstack-from-template
|
|
16
|
+
title: Create AppStack from Template
|
|
17
|
+
description: Create a new AppStack by cloning topology from a StackGen template AppStack
|
|
18
|
+
tags:
|
|
19
|
+
- infrastructure
|
|
20
|
+
- stackgen
|
|
21
|
+
spec:
|
|
22
|
+
owner: user:guest
|
|
23
|
+
type: service
|
|
24
|
+
parameters:
|
|
25
|
+
- title: Destination
|
|
26
|
+
required:
|
|
27
|
+
- teamId
|
|
28
|
+
- appstackName
|
|
29
|
+
properties:
|
|
30
|
+
teamId:
|
|
31
|
+
type: string
|
|
32
|
+
title: Team / Project
|
|
33
|
+
description: Destination team (project) for the new AppStack
|
|
34
|
+
ui:field: TeamSelect
|
|
35
|
+
appstackName:
|
|
36
|
+
type: string
|
|
37
|
+
title: AppStack Name
|
|
38
|
+
description: Name for the new AppStack
|
|
39
|
+
minLength: 4
|
|
40
|
+
pattern: "^[a-z]+(?:-[a-z]+)*$"
|
|
41
|
+
ui:autofocus: true
|
|
42
|
+
cloudProvider:
|
|
43
|
+
type: string
|
|
44
|
+
title: Cloud Provider (optional)
|
|
45
|
+
description: Overrides provider from the template when set (e.g. aws, gcp, azure)
|
|
46
|
+
enum:
|
|
47
|
+
- aws
|
|
48
|
+
- gcp
|
|
49
|
+
- azure
|
|
50
|
+
|
|
51
|
+
- title: Template AppStack
|
|
52
|
+
required:
|
|
53
|
+
- templateAppstackId
|
|
54
|
+
properties:
|
|
55
|
+
templateAppstackId:
|
|
56
|
+
type: string
|
|
57
|
+
title: Template AppStack
|
|
58
|
+
description: StackGen template AppStack to clone
|
|
59
|
+
ui:field: TemplateAppStackSelect
|
|
60
|
+
|
|
61
|
+
steps:
|
|
62
|
+
- id: createAppStack
|
|
63
|
+
name: Create AppStack from Template
|
|
64
|
+
action: stackGen:createAppStack
|
|
65
|
+
input:
|
|
66
|
+
appstack:
|
|
67
|
+
name: ${{ parameters.appstackName }}
|
|
68
|
+
teamId: ${{ parameters.teamId }}
|
|
69
|
+
templateAppstackId: ${{ parameters.templateAppstackId }}
|
|
70
|
+
cloudProvider: ${{ parameters.cloudProvider }}
|
|
71
|
+
resources: []
|
|
72
|
+
|
|
73
|
+
output:
|
|
74
|
+
links:
|
|
75
|
+
- title: View Created AppStack in StackGen
|
|
76
|
+
url: ${{ steps.createAppStack.output.appStackURL }}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Create AppStack with Modules
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Creates an AppStack in an existing team and adds selected catalog modules.
|
|
5
|
+
# Demonstrates TeamSelect + ModuleSelect; ModuleSelect values are coerced to
|
|
6
|
+
# custom-module resources by stackGen:createAppStack.
|
|
7
|
+
# =============================================================================
|
|
8
|
+
apiVersion: scaffolder.backstage.io/v1beta3
|
|
9
|
+
kind: Template
|
|
10
|
+
metadata:
|
|
11
|
+
name: stackgen-appstack-with-modules
|
|
12
|
+
title: Create AppStack with Modules
|
|
13
|
+
description: Create an AppStack and attach selected StackGen catalog modules
|
|
14
|
+
tags:
|
|
15
|
+
- stackgen
|
|
16
|
+
- appstack
|
|
17
|
+
- modules
|
|
18
|
+
spec:
|
|
19
|
+
owner: user:guest
|
|
20
|
+
type: service
|
|
21
|
+
parameters:
|
|
22
|
+
- title: AppStack
|
|
23
|
+
required:
|
|
24
|
+
- teamId
|
|
25
|
+
- appstackName
|
|
26
|
+
properties:
|
|
27
|
+
teamId:
|
|
28
|
+
title: Team / Project
|
|
29
|
+
type: string
|
|
30
|
+
ui:field: TeamSelect
|
|
31
|
+
appstackName:
|
|
32
|
+
title: AppStack Name
|
|
33
|
+
type: string
|
|
34
|
+
description: Name of the AppStack to create
|
|
35
|
+
minLength: 3
|
|
36
|
+
pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
|
37
|
+
cloudProvider:
|
|
38
|
+
title: Cloud Provider
|
|
39
|
+
type: string
|
|
40
|
+
default: aws
|
|
41
|
+
enum:
|
|
42
|
+
- aws
|
|
43
|
+
- azure
|
|
44
|
+
- gcp
|
|
45
|
+
modules:
|
|
46
|
+
title: Catalog Modules
|
|
47
|
+
type: array
|
|
48
|
+
description: Select one or more modules (label + version)
|
|
49
|
+
ui:field: ModuleSelect
|
|
50
|
+
ui:options:
|
|
51
|
+
teamId: teamId
|
|
52
|
+
|
|
53
|
+
steps:
|
|
54
|
+
- id: createAppStack
|
|
55
|
+
name: Create AppStack with Modules
|
|
56
|
+
action: stackGen:createAppStack
|
|
57
|
+
input:
|
|
58
|
+
appstack:
|
|
59
|
+
name: ${{ parameters.appstackName }}
|
|
60
|
+
cloudProvider: ${{ parameters.cloudProvider }}
|
|
61
|
+
teamId: ${{ parameters.teamId }}
|
|
62
|
+
# ModuleSelect objects ({ id, label, versionName }) are accepted and
|
|
63
|
+
# normalized to vibe-coded-module resources with templateId = id.
|
|
64
|
+
resources: ${{ parameters.modules }}
|
|
65
|
+
|
|
66
|
+
output:
|
|
67
|
+
links:
|
|
68
|
+
- title: View AppStack in StackGen
|
|
69
|
+
url: ${{ steps.createAppStack.output.appStackURL }}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Create AppStack with Resources
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Creates a project with environments, then an AppStack populated with a
|
|
5
|
+
# resource pack, a standalone S3 bucket, and a custom Terraform module.
|
|
6
|
+
#
|
|
7
|
+
# This template demonstrates all three ways to add resources to an AppStack:
|
|
8
|
+
# • Resource packs — pre-configured bundles of resources (via resourcePackId)
|
|
9
|
+
# • Standalone resources — individual resources like S3 (via resourceType)
|
|
10
|
+
# • Custom modules — user-authored Terraform modules (via templateId)
|
|
11
|
+
#
|
|
12
|
+
# All three use the same POST /iac-gen/v1/topologies/{id}/resources API.
|
|
13
|
+
# =============================================================================
|
|
14
|
+
apiVersion: scaffolder.backstage.io/v1beta3
|
|
15
|
+
kind: Template
|
|
16
|
+
metadata:
|
|
17
|
+
name: stackgen-appstack-with-resources
|
|
18
|
+
title: Create AppStack with Resources
|
|
19
|
+
description: Create a project and an AppStack with a resource pack, standalone S3 bucket, and custom Terraform module
|
|
20
|
+
spec:
|
|
21
|
+
owner: user:guest
|
|
22
|
+
type: service
|
|
23
|
+
parameters:
|
|
24
|
+
- title: Configuration
|
|
25
|
+
required:
|
|
26
|
+
- projectName
|
|
27
|
+
- serviceName
|
|
28
|
+
properties:
|
|
29
|
+
projectName:
|
|
30
|
+
type: string
|
|
31
|
+
title: Project Name
|
|
32
|
+
description: Name of the project (team) to create
|
|
33
|
+
serviceName:
|
|
34
|
+
type: string
|
|
35
|
+
title: Service Name
|
|
36
|
+
description: Name of the AppStack to create
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- id: createProject
|
|
40
|
+
name: Create Project
|
|
41
|
+
action: stackGen:createProject
|
|
42
|
+
input:
|
|
43
|
+
project:
|
|
44
|
+
name: ${{ parameters.projectName }}
|
|
45
|
+
description: "Project created via Backstage Scaffolder"
|
|
46
|
+
environmentConfig:
|
|
47
|
+
name: "default"
|
|
48
|
+
environmentTemplates:
|
|
49
|
+
- name: "dev"
|
|
50
|
+
color: "#1cbb9b"
|
|
51
|
+
- name: "stage"
|
|
52
|
+
color: "#f0ad4e"
|
|
53
|
+
- name: "prod"
|
|
54
|
+
color: "#e83e8c"
|
|
55
|
+
|
|
56
|
+
- id: createAppStack
|
|
57
|
+
name: Create AppStack
|
|
58
|
+
action: stackGen:createAppStack
|
|
59
|
+
input:
|
|
60
|
+
appstack:
|
|
61
|
+
name: ${{ parameters.serviceName }}
|
|
62
|
+
cloudProvider: "aws"
|
|
63
|
+
teamId: ${{ steps.createProject.output.teamId }}
|
|
64
|
+
resources:
|
|
65
|
+
# Resource pack — a pre-configured bundle of resources
|
|
66
|
+
- resourceType: resourcePack
|
|
67
|
+
resourcePackId: 03c4d48d-0b01-4110-80de-9ac351545329
|
|
68
|
+
# Standalone resource — an individual S3 bucket
|
|
69
|
+
- resourceType: aws_s3
|
|
70
|
+
name: my-extra-s3-bucket
|
|
71
|
+
# Custom module — a user-authored Terraform module added via
|
|
72
|
+
# templateId. This is how custom modules can be added to an
|
|
73
|
+
# AppStack programmatically using the same topology resources API.
|
|
74
|
+
- resourceType: vibe-coded-module
|
|
75
|
+
iacType: Terraform
|
|
76
|
+
templateId: 68a391f8-0e6b-41fb-b993-75905e9f211e
|
|
77
|
+
|
|
78
|
+
output:
|
|
79
|
+
links:
|
|
80
|
+
- title: "View AppStack in StackGen"
|
|
81
|
+
url: ${{ steps.createAppStack.output.appStackURL }}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Export IaC to GitHub
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Downloads Infrastructure as Code (IaC) from an existing StackGen AppStack
|
|
5
|
+
# and opens a Pull Request on a GitHub repository of your choice.
|
|
6
|
+
#
|
|
7
|
+
# Workflow:
|
|
8
|
+
# 1. Select a Team (project) from StackGen
|
|
9
|
+
# 2. Select an AppStack belonging to that team
|
|
10
|
+
# 3. Specify a target GitHub repo, directory path, and GitHub PAT
|
|
11
|
+
# 4. Backstage downloads the IaC via the StackGen API
|
|
12
|
+
# 5. A Pull Request is opened on the target repo's main branch
|
|
13
|
+
#
|
|
14
|
+
# Prerequisites:
|
|
15
|
+
# - A valid StackGen AppStack must already exist
|
|
16
|
+
# - A GitHub PAT with repo write and PR permissions
|
|
17
|
+
# =============================================================================
|
|
18
|
+
apiVersion: scaffolder.backstage.io/v1beta3
|
|
19
|
+
kind: Template
|
|
20
|
+
metadata:
|
|
21
|
+
name: stackgen-export-iac
|
|
22
|
+
title: Export IaC to GitHub
|
|
23
|
+
description: Manually fetch IaC from an AppStack and push it to GitHub via Backstage — useful when you prefer Backstage to handle the git push instead of StackGen's native git integration
|
|
24
|
+
spec:
|
|
25
|
+
owner: user:guest
|
|
26
|
+
type: service
|
|
27
|
+
parameters:
|
|
28
|
+
# Step 1: Select a team/project from StackGen.
|
|
29
|
+
- title: Select Team
|
|
30
|
+
properties:
|
|
31
|
+
teamId:
|
|
32
|
+
type: string
|
|
33
|
+
title: Team ID
|
|
34
|
+
ui:field: TeamSelect
|
|
35
|
+
|
|
36
|
+
# Step 2: Select an AppStack belonging to the chosen team.
|
|
37
|
+
- title: Select Appstack
|
|
38
|
+
required:
|
|
39
|
+
- name
|
|
40
|
+
properties:
|
|
41
|
+
name:
|
|
42
|
+
type: string
|
|
43
|
+
title: AppStack Name
|
|
44
|
+
ui:field: AppStackSelect
|
|
45
|
+
ui:options:
|
|
46
|
+
teamId: teamId
|
|
47
|
+
|
|
48
|
+
# Step 3: Target GitHub repo, IaC path, and authentication.
|
|
49
|
+
- title: Choose a location
|
|
50
|
+
required:
|
|
51
|
+
- repoUrl
|
|
52
|
+
properties:
|
|
53
|
+
repoUrl:
|
|
54
|
+
title: Repository Location
|
|
55
|
+
type: string
|
|
56
|
+
ui:field: RepoUrlPicker
|
|
57
|
+
ui:options:
|
|
58
|
+
allowedHosts:
|
|
59
|
+
- github.com
|
|
60
|
+
path:
|
|
61
|
+
title: Path For IaC
|
|
62
|
+
type: string
|
|
63
|
+
description: Directory to store the IaC files in the repository
|
|
64
|
+
default: "infrastructure"
|
|
65
|
+
token:
|
|
66
|
+
type: string
|
|
67
|
+
ui:field: Secret
|
|
68
|
+
title: GitHub Token
|
|
69
|
+
|
|
70
|
+
steps:
|
|
71
|
+
- id: stackGenIaCDownload
|
|
72
|
+
name: Download IaC for appStack
|
|
73
|
+
action: stackGen:downloadIaC
|
|
74
|
+
input:
|
|
75
|
+
appstackName: ${{ parameters.name }}
|
|
76
|
+
teamId: ${{ parameters.teamId }}
|
|
77
|
+
extractedIaCPath: ${{ parameters.path }}
|
|
78
|
+
|
|
79
|
+
- id: createPR
|
|
80
|
+
name: Create Pull Request for IAC
|
|
81
|
+
action: publish:github:pull-request
|
|
82
|
+
input:
|
|
83
|
+
repoUrl: ${{ parameters.repoUrl }}
|
|
84
|
+
token: "${{ secrets.token }}"
|
|
85
|
+
branchName: iac-${{ parameters.name }}
|
|
86
|
+
targetBranchName: main
|
|
87
|
+
title: Add IaC files for ${{ parameters.name }}
|
|
88
|
+
description: PR auto-created for IaC generated from Stackgen
|
|
89
|
+
sourcePath: ${{ parameters.path }}
|
|
90
|
+
targetPath: ${{ parameters.path }}
|
|
91
|
+
update: true
|
|
92
|
+
commitMessage: added IaC files
|
|
93
|
+
|
|
94
|
+
output:
|
|
95
|
+
links:
|
|
96
|
+
- title: "View IaC Pull Request"
|
|
97
|
+
url: ${{ steps.createPR.output.remoteUrl }}
|