@appliance.sh/infra 1.18.0 → 1.19.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appliance.sh/infra",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "Deploy the Appliance Infrastructure",
|
|
5
5
|
"repository": "https://github.com/appliance-sh/appliance.sh",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dev:setup": "npm link"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@appliance.sh/sdk": "1.
|
|
26
|
+
"@appliance.sh/sdk": "1.19.0",
|
|
27
27
|
"@pulumi/aws": "^7.16.0",
|
|
28
28
|
"@pulumi/aws-native": "^1.48.0",
|
|
29
29
|
"@pulumi/awsx": "^3.1.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as auto from '@pulumi/pulumi/automation';
|
|
2
2
|
import * as aws from '@pulumi/aws';
|
|
3
3
|
import * as awsNative from '@pulumi/aws-native';
|
|
4
|
-
import { ApplianceStack, toResourceId } from './aws/ApplianceStack';
|
|
4
|
+
import { ApplianceStack, ApplianceStackMetadata, toResourceId } from './aws/ApplianceStack';
|
|
5
5
|
import { applianceBaseConfig, ApplianceBaseConfig } from '@appliance.sh/sdk';
|
|
6
6
|
|
|
7
7
|
export type PulumiAction = 'deploy' | 'destroy';
|
|
@@ -32,7 +32,7 @@ export class ApplianceDeploymentService {
|
|
|
32
32
|
this.region = this.baseConfig?.aws.region || 'us-east-1';
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
private inlineProgram(stackName: string) {
|
|
35
|
+
private inlineProgram(stackName: string, metadata?: ApplianceStackMetadata) {
|
|
36
36
|
return async () => {
|
|
37
37
|
if (!this.baseConfig) {
|
|
38
38
|
throw new Error('Missing base config');
|
|
@@ -56,7 +56,7 @@ export class ApplianceDeploymentService {
|
|
|
56
56
|
const applianceStack = new ApplianceStack(
|
|
57
57
|
stackName,
|
|
58
58
|
{
|
|
59
|
-
|
|
59
|
+
metadata,
|
|
60
60
|
config: this.baseConfig,
|
|
61
61
|
},
|
|
62
62
|
{
|
|
@@ -73,8 +73,8 @@ export class ApplianceDeploymentService {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
private async getOrCreateStack(stackName: string): Promise<auto.Stack> {
|
|
77
|
-
const program = this.inlineProgram(stackName);
|
|
76
|
+
private async getOrCreateStack(stackName: string, metadata?: ApplianceStackMetadata): Promise<auto.Stack> {
|
|
77
|
+
const program = this.inlineProgram(stackName, metadata);
|
|
78
78
|
const envVars: Record<string, string> = {
|
|
79
79
|
AWS_REGION: this.region,
|
|
80
80
|
};
|
|
@@ -112,8 +112,8 @@ export class ApplianceDeploymentService {
|
|
|
112
112
|
return auto.Stack.createOrSelect(stackName, ws);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
async deploy(stackName
|
|
116
|
-
const stack = await this.getOrCreateStack(stackName);
|
|
115
|
+
async deploy(stackName: string, metadata?: ApplianceStackMetadata): Promise<PulumiResult> {
|
|
116
|
+
const stack = await this.getOrCreateStack(stackName, metadata);
|
|
117
117
|
const result = await stack.up({ onOutput: (m) => console.log(m) });
|
|
118
118
|
const changes = result.summary.resourceChanges || {};
|
|
119
119
|
const totalChanges = Object.entries(changes)
|
|
@@ -129,7 +129,7 @@ export class ApplianceDeploymentService {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
async destroy(stackName
|
|
132
|
+
async destroy(stackName: string): Promise<PulumiResult> {
|
|
133
133
|
try {
|
|
134
134
|
const stack = await this.selectExistingStack(stackName);
|
|
135
135
|
await stack.destroy({ onOutput: (m) => console.log(m) });
|
|
@@ -35,8 +35,17 @@ export function toDnsLabel(name: string): string {
|
|
|
35
35
|
return truncateWithHash(name, MAX_DNS_LABEL_LENGTH);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
export interface ApplianceStackMetadata {
|
|
39
|
+
projectId: string;
|
|
40
|
+
projectName: string;
|
|
41
|
+
environmentId: string;
|
|
42
|
+
environmentName: string;
|
|
43
|
+
deploymentId: string;
|
|
44
|
+
stackName: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
export interface ApplianceStackArgs {
|
|
39
|
-
|
|
48
|
+
metadata?: ApplianceStackMetadata;
|
|
40
49
|
config: ApplianceBaseConfig;
|
|
41
50
|
}
|
|
42
51
|
|
|
@@ -64,7 +73,17 @@ export class ApplianceStack extends pulumi.ComponentResource {
|
|
|
64
73
|
|
|
65
74
|
const defaultOpts = { parent: this, provider: opts.provider };
|
|
66
75
|
const defaultNativeOpts = { parent: this, provider: opts.nativeProvider };
|
|
67
|
-
const defaultTags
|
|
76
|
+
const defaultTags: Record<string, string> = {
|
|
77
|
+
'appliance:managed': 'true',
|
|
78
|
+
'appliance:stack-name': name,
|
|
79
|
+
};
|
|
80
|
+
if (args.metadata) {
|
|
81
|
+
defaultTags['appliance:project-id'] = args.metadata.projectId;
|
|
82
|
+
defaultTags['appliance:project-name'] = args.metadata.projectName;
|
|
83
|
+
defaultTags['appliance:environment-id'] = args.metadata.environmentId;
|
|
84
|
+
defaultTags['appliance:environment-name'] = args.metadata.environmentName;
|
|
85
|
+
defaultTags['appliance:deployment-id'] = args.metadata.deploymentId;
|
|
86
|
+
}
|
|
68
87
|
|
|
69
88
|
this.lambdaRole = new aws.iam.Role(`${rid}-role`, {
|
|
70
89
|
path: `/appliance/${name}/`,
|