@studion/infra-code-blocks 0.8.0-next.2 → 2.0.0-alpha.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/dist/components/acm-certificate/index.d.ts +20 -0
- package/dist/components/acm-certificate/index.d.ts.map +1 -0
- package/dist/components/acm-certificate/index.js +40 -0
- package/dist/components/cloudfront/index.d.ts +92 -0
- package/dist/components/cloudfront/index.d.ts.map +1 -0
- package/dist/components/cloudfront/index.js +208 -0
- package/dist/components/cloudfront/lb-cache-strategy.d.ts +21 -0
- package/dist/components/cloudfront/lb-cache-strategy.d.ts.map +1 -0
- package/dist/components/cloudfront/lb-cache-strategy.js +93 -0
- package/dist/components/cloudfront/s3-cache-strategy.d.ts +21 -0
- package/dist/components/cloudfront/s3-cache-strategy.d.ts.map +1 -0
- package/dist/components/cloudfront/s3-cache-strategy.js +78 -0
- package/dist/components/cloudfront/types.d.ts +10 -0
- package/dist/components/cloudfront/types.d.ts.map +1 -0
- package/dist/components/database/builder.d.ts +32 -0
- package/dist/components/database/builder.d.ts.map +1 -0
- package/dist/components/database/builder.js +82 -0
- package/dist/components/database/database-replica.d.ts +35 -0
- package/dist/components/database/database-replica.d.ts.map +1 -0
- package/dist/components/database/database-replica.js +40 -0
- package/dist/components/database/ec2-ssm-connect.d.ts +26 -0
- package/dist/components/database/ec2-ssm-connect.d.ts.map +1 -0
- package/dist/components/{ec2-ssm-connect.js → database/ec2-ssm-connect.js} +42 -34
- package/dist/components/database/index.d.ts +67 -0
- package/dist/components/database/index.d.ts.map +1 -0
- package/dist/components/database/index.js +144 -0
- package/dist/{v2/components → components}/ecs-service/index.d.ts +6 -5
- package/dist/components/ecs-service/index.d.ts.map +1 -0
- package/dist/{v2/components → components}/ecs-service/index.js +19 -30
- package/dist/components/ecs-service/policies.d.ts +3 -0
- package/dist/components/ecs-service/policies.d.ts.map +1 -0
- package/dist/components/ecs-service/task-size.d.ts +37 -0
- package/dist/components/ecs-service/task-size.d.ts.map +1 -0
- package/dist/{constants.js → components/ecs-service/task-size.js} +17 -7
- package/dist/components/grafana/dashboards/index.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/panels.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/types.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/web-server-slo.d.ts.map +1 -0
- package/dist/components/grafana/index.d.ts.map +1 -0
- package/dist/components/password/index.d.ts +15 -0
- package/dist/components/password/index.d.ts.map +1 -0
- package/dist/components/{password.js → password/index.js} +6 -9
- package/dist/components/prometheus/index.d.ts.map +1 -0
- package/dist/components/prometheus/queries.d.ts.map +1 -0
- package/dist/components/prometheus/queries.test.d.ts.map +1 -0
- package/dist/components/redis/elasticache-redis.d.ts +38 -0
- package/dist/components/redis/elasticache-redis.d.ts.map +1 -0
- package/dist/components/redis/elasticache-redis.js +58 -0
- package/dist/components/redis/upstash-redis.d.ts +20 -0
- package/dist/components/redis/upstash-redis.d.ts.map +1 -0
- package/dist/components/redis/upstash-redis.js +29 -0
- package/dist/components/static-site/index.d.ts +23 -0
- package/dist/components/static-site/index.d.ts.map +1 -0
- package/dist/components/static-site/index.js +32 -0
- package/dist/components/static-site/s3-assets.d.ts +20 -0
- package/dist/components/static-site/s3-assets.d.ts.map +1 -0
- package/dist/components/static-site/s3-assets.js +63 -0
- package/dist/components/vpc/index.d.ts +20 -0
- package/dist/components/vpc/index.d.ts.map +1 -0
- package/dist/components/vpc/index.js +31 -0
- package/dist/{v2/components → components}/web-server/builder.d.ts +6 -2
- package/dist/components/web-server/builder.d.ts.map +1 -0
- package/dist/{v2/components → components}/web-server/builder.js +11 -1
- package/dist/{v2/components → components}/web-server/index.d.ts +30 -8
- package/dist/components/web-server/index.d.ts.map +1 -0
- package/dist/{v2/components → components}/web-server/index.js +49 -40
- package/dist/{v2/components → components}/web-server/load-balancer.d.ts +4 -3
- package/dist/components/web-server/load-balancer.d.ts.map +1 -0
- package/dist/{v2/components → components}/web-server/load-balancer.js +17 -14
- package/dist/index.d.ts +24 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -26
- package/dist/otel/batch-processor.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/builder.d.ts +15 -2
- package/dist/otel/builder.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/builder.js +47 -2
- package/dist/{v2/otel → otel}/config.d.ts +13 -1
- package/dist/otel/config.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/config.js +20 -3
- package/dist/{v2/otel → otel}/index.d.ts +8 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/memory-limiter-processor.d.ts.map +1 -0
- package/dist/otel/otlp-receiver.d.ts.map +1 -0
- package/dist/otel/prometheus-remote-write-exporter.d.ts.map +1 -0
- package/dist/shared/common-tags.d.ts +5 -0
- package/dist/shared/common-tags.d.ts.map +1 -0
- package/dist/shared/common-tags.js +8 -0
- package/dist/shared/merge-with-defaults.d.ts +2 -0
- package/dist/shared/merge-with-defaults.d.ts.map +1 -0
- package/dist/shared/merge-with-defaults.js +7 -0
- package/package.json +32 -14
- package/dist/components/acm-certificate.d.ts +0 -11
- package/dist/components/acm-certificate.d.ts.map +0 -1
- package/dist/components/acm-certificate.js +0 -30
- package/dist/components/database-replica.d.ts +0 -69
- package/dist/components/database-replica.d.ts.map +0 -1
- package/dist/components/database-replica.js +0 -40
- package/dist/components/database.d.ts +0 -99
- package/dist/components/database.d.ts.map +0 -1
- package/dist/components/database.js +0 -118
- package/dist/components/ec2-ssm-connect.d.ts +0 -22
- package/dist/components/ec2-ssm-connect.d.ts.map +0 -1
- package/dist/components/ecs-service.d.ts +0 -143
- package/dist/components/ecs-service.d.ts.map +0 -1
- package/dist/components/ecs-service.js +0 -357
- package/dist/components/mongo.d.ts +0 -39
- package/dist/components/mongo.d.ts.map +0 -1
- package/dist/components/mongo.js +0 -54
- package/dist/components/nuxt-ssr.d.ts +0 -44
- package/dist/components/nuxt-ssr.d.ts.map +0 -1
- package/dist/components/nuxt-ssr.js +0 -277
- package/dist/components/password.d.ts +0 -13
- package/dist/components/password.d.ts.map +0 -1
- package/dist/components/project.d.ts +0 -77
- package/dist/components/project.d.ts.map +0 -1
- package/dist/components/project.js +0 -171
- package/dist/components/redis.d.ts +0 -23
- package/dist/components/redis.d.ts.map +0 -1
- package/dist/components/redis.js +0 -35
- package/dist/components/static-site.d.ts +0 -36
- package/dist/components/static-site.d.ts.map +0 -1
- package/dist/components/static-site.js +0 -138
- package/dist/components/web-server.d.ts +0 -38
- package/dist/components/web-server.d.ts.map +0 -1
- package/dist/components/web-server.js +0 -185
- package/dist/constants.d.ts +0 -23
- package/dist/constants.d.ts.map +0 -1
- package/dist/types/pulumi.d.ts +0 -5
- package/dist/types/pulumi.d.ts.map +0 -1
- package/dist/types/size.d.ts +0 -8
- package/dist/types/size.d.ts.map +0 -1
- package/dist/types/size.js +0 -2
- package/dist/v2/components/ecs-service/index.d.ts.map +0 -1
- package/dist/v2/components/ecs-service/policies.d.ts +0 -3
- package/dist/v2/components/ecs-service/policies.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/index.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/panels.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/types.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/web-server-slo.d.ts.map +0 -1
- package/dist/v2/components/grafana/index.d.ts.map +0 -1
- package/dist/v2/components/prometheus/index.d.ts.map +0 -1
- package/dist/v2/components/prometheus/queries.d.ts.map +0 -1
- package/dist/v2/components/prometheus/queries.test.d.ts.map +0 -1
- package/dist/v2/components/web-server/builder.d.ts.map +0 -1
- package/dist/v2/components/web-server/index.d.ts.map +0 -1
- package/dist/v2/components/web-server/load-balancer.d.ts.map +0 -1
- package/dist/v2/index.d.ts +0 -13
- package/dist/v2/index.d.ts.map +0 -1
- package/dist/v2/index.js +0 -16
- package/dist/v2/otel/batch-processor.d.ts.map +0 -1
- package/dist/v2/otel/builder.d.ts.map +0 -1
- package/dist/v2/otel/config.d.ts.map +0 -1
- package/dist/v2/otel/index.d.ts.map +0 -1
- package/dist/v2/otel/memory-limiter-processor.d.ts.map +0 -1
- package/dist/v2/otel/otlp-receiver.d.ts.map +0 -1
- package/dist/v2/otel/prometheus-remote-write-exporter.d.ts.map +0 -1
- /package/dist/{v2/components/grafana/dashboards → components/cloudfront}/types.js +0 -0
- /package/dist/{v2/components → components}/ecs-service/policies.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/index.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/index.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/panels.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/panels.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/types.d.ts +0 -0
- /package/dist/{types/pulumi.js → components/grafana/dashboards/types.js} +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/web-server-slo.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/web-server-slo.js +0 -0
- /package/dist/{v2/components → components}/grafana/index.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/index.js +0 -0
- /package/dist/{v2/components → components}/prometheus/index.d.ts +0 -0
- /package/dist/{v2/components → components}/prometheus/index.js +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.d.ts +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.js +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.test.d.ts +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.test.js +0 -0
- /package/dist/{v2/otel → otel}/batch-processor.d.ts +0 -0
- /package/dist/{v2/otel → otel}/batch-processor.js +0 -0
- /package/dist/{v2/otel → otel}/index.js +0 -0
- /package/dist/{v2/otel → otel}/memory-limiter-processor.d.ts +0 -0
- /package/dist/{v2/otel → otel}/memory-limiter-processor.js +0 -0
- /package/dist/{v2/otel → otel}/otlp-receiver.d.ts +0 -0
- /package/dist/{v2/otel → otel}/otlp-receiver.js +0 -0
- /package/dist/{v2/otel → otel}/prometheus-remote-write-exporter.d.ts +0 -0
- /package/dist/{v2/otel → otel}/prometheus-remote-write-exporter.js +0 -0
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Database = void 0;
|
|
4
|
-
const aws = require("@pulumi/aws");
|
|
5
|
-
const pulumi = require("@pulumi/pulumi");
|
|
6
|
-
const password_1 = require("./password");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const defaults = {
|
|
9
|
-
multiAz: false,
|
|
10
|
-
applyImmediately: false,
|
|
11
|
-
skipFinalSnapshot: false,
|
|
12
|
-
allocatedStorage: 20,
|
|
13
|
-
maxAllocatedStorage: 100,
|
|
14
|
-
instanceClass: 'db.t4g.micro',
|
|
15
|
-
enableMonitoring: false,
|
|
16
|
-
allowMajorVersionUpgrade: false,
|
|
17
|
-
engineVersion: '17.2',
|
|
18
|
-
};
|
|
19
|
-
class Database extends pulumi.ComponentResource {
|
|
20
|
-
constructor(name, args, opts = {}) {
|
|
21
|
-
super('studion:Database', name, {}, opts);
|
|
22
|
-
this.name = name;
|
|
23
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
24
|
-
const { vpcId, isolatedSubnetIds, vpcCidrBlock, enableMonitoring, snapshotIdentifier, } = argsWithDefaults;
|
|
25
|
-
this.dbSubnetGroup = this.createSubnetGroup({ isolatedSubnetIds });
|
|
26
|
-
this.dbSecurityGroup = this.createSecurityGroup({ vpcId, vpcCidrBlock });
|
|
27
|
-
this.kms = this.createEncryptionKey();
|
|
28
|
-
this.password = new password_1.Password(`${this.name}-database-password`, { value: args.password }, { parent: this });
|
|
29
|
-
if (enableMonitoring) {
|
|
30
|
-
this.monitoringRole = this.createMonitoringRole();
|
|
31
|
-
}
|
|
32
|
-
if (snapshotIdentifier) {
|
|
33
|
-
this.encryptedSnapshotCopy =
|
|
34
|
-
this.createEncryptedSnapshotCopy(snapshotIdentifier);
|
|
35
|
-
}
|
|
36
|
-
this.instance = this.createDatabaseInstance(args);
|
|
37
|
-
this.registerOutputs();
|
|
38
|
-
}
|
|
39
|
-
createSubnetGroup({ isolatedSubnetIds, }) {
|
|
40
|
-
const dbSubnetGroup = new aws.rds.SubnetGroup(`${this.name}-subnet-group`, {
|
|
41
|
-
subnetIds: isolatedSubnetIds,
|
|
42
|
-
tags: constants_1.commonTags,
|
|
43
|
-
}, { parent: this });
|
|
44
|
-
return dbSubnetGroup;
|
|
45
|
-
}
|
|
46
|
-
createSecurityGroup({ vpcId, vpcCidrBlock, }) {
|
|
47
|
-
const dbSecurityGroup = new aws.ec2.SecurityGroup(`${this.name}-security-group`, {
|
|
48
|
-
vpcId,
|
|
49
|
-
ingress: [
|
|
50
|
-
{
|
|
51
|
-
protocol: 'tcp',
|
|
52
|
-
fromPort: 5432,
|
|
53
|
-
toPort: 5432,
|
|
54
|
-
cidrBlocks: [vpcCidrBlock],
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
tags: constants_1.commonTags,
|
|
58
|
-
}, { parent: this });
|
|
59
|
-
return dbSecurityGroup;
|
|
60
|
-
}
|
|
61
|
-
createEncryptionKey() {
|
|
62
|
-
const kms = new aws.kms.Key(`${this.name}-rds-key`, {
|
|
63
|
-
description: `${this.name} RDS encryption key`,
|
|
64
|
-
customerMasterKeySpec: 'SYMMETRIC_DEFAULT',
|
|
65
|
-
isEnabled: true,
|
|
66
|
-
keyUsage: 'ENCRYPT_DECRYPT',
|
|
67
|
-
multiRegion: false,
|
|
68
|
-
enableKeyRotation: true,
|
|
69
|
-
tags: constants_1.commonTags,
|
|
70
|
-
}, { parent: this });
|
|
71
|
-
return kms;
|
|
72
|
-
}
|
|
73
|
-
createMonitoringRole() {
|
|
74
|
-
const monitoringRole = new aws.iam.Role(`${this.name}-rds-monitoring`, {
|
|
75
|
-
assumeRolePolicy: {
|
|
76
|
-
Version: '2012-10-17',
|
|
77
|
-
Statement: [
|
|
78
|
-
{
|
|
79
|
-
Action: 'sts:AssumeRole',
|
|
80
|
-
Effect: 'Allow',
|
|
81
|
-
Principal: {
|
|
82
|
-
Service: 'monitoring.rds.amazonaws.com',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
new aws.iam.RolePolicyAttachment(`${this.name}-rds-monitoring-role-attachment`, {
|
|
89
|
-
role: monitoringRole.name,
|
|
90
|
-
policyArn: 'arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole',
|
|
91
|
-
});
|
|
92
|
-
return monitoringRole;
|
|
93
|
-
}
|
|
94
|
-
createEncryptedSnapshotCopy(snapshotIdentifier) {
|
|
95
|
-
const encryptedSnapshotCopy = new aws.rds.SnapshotCopy(`${this.name}-encrypted-snapshot-copy`, {
|
|
96
|
-
sourceDbSnapshotIdentifier: snapshotIdentifier,
|
|
97
|
-
targetDbSnapshotIdentifier: `${snapshotIdentifier}-encrypted-copy`,
|
|
98
|
-
kmsKeyId: this.kms.arn,
|
|
99
|
-
}, { parent: this });
|
|
100
|
-
return encryptedSnapshotCopy;
|
|
101
|
-
}
|
|
102
|
-
createDatabaseInstance(args) {
|
|
103
|
-
var _a;
|
|
104
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
105
|
-
const stack = pulumi.getStack();
|
|
106
|
-
const monitoringOptions = argsWithDefaults.enableMonitoring && this.monitoringRole
|
|
107
|
-
? {
|
|
108
|
-
monitoringInterval: 60,
|
|
109
|
-
monitoringRoleArn: this.monitoringRole.arn,
|
|
110
|
-
performanceInsightsEnabled: true,
|
|
111
|
-
performanceInsightsRetentionPeriod: 7,
|
|
112
|
-
}
|
|
113
|
-
: {};
|
|
114
|
-
const instance = new aws.rds.Instance(`${this.name}-rds`, Object.assign(Object.assign({ identifierPrefix: `${this.name}-`, engine: 'postgres', engineVersion: argsWithDefaults.engineVersion, allocatedStorage: argsWithDefaults.allocatedStorage, maxAllocatedStorage: argsWithDefaults.maxAllocatedStorage, instanceClass: argsWithDefaults.instanceClass, dbName: argsWithDefaults.dbName, username: argsWithDefaults.username, password: this.password.value, dbSubnetGroupName: this.dbSubnetGroup.name, vpcSecurityGroupIds: [this.dbSecurityGroup.id], storageEncrypted: true, kmsKeyId: this.kms.arn, multiAz: argsWithDefaults.multiAz, publiclyAccessible: false, skipFinalSnapshot: argsWithDefaults.skipFinalSnapshot, applyImmediately: argsWithDefaults.applyImmediately, autoMinorVersionUpgrade: true, maintenanceWindow: 'Mon:07:00-Mon:07:30', finalSnapshotIdentifier: `${this.name}-final-snapshot-${stack}`, backupWindow: '06:00-06:30', backupRetentionPeriod: 14, caCertIdentifier: 'rds-ca-rsa2048-g1', parameterGroupName: argsWithDefaults.parameterGroupName, allowMajorVersionUpgrade: argsWithDefaults.allowMajorVersionUpgrade, snapshotIdentifier: (_a = this.encryptedSnapshotCopy) === null || _a === void 0 ? void 0 : _a.targetDbSnapshotIdentifier }, monitoringOptions), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this, dependsOn: [this.password] });
|
|
115
|
-
return instance;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exports.Database = Database;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
-
import * as aws from '@pulumi/aws';
|
|
3
|
-
export type Ec2SSMConnectArgs = {
|
|
4
|
-
vpcId: pulumi.Input<string>;
|
|
5
|
-
privateSubnetId: pulumi.Input<string>;
|
|
6
|
-
/**
|
|
7
|
-
* The IPv4 CIDR block for the VPC.
|
|
8
|
-
*/
|
|
9
|
-
vpcCidrBlock: pulumi.Input<string>;
|
|
10
|
-
tags?: pulumi.Input<{
|
|
11
|
-
[key: string]: pulumi.Input<string>;
|
|
12
|
-
}>;
|
|
13
|
-
};
|
|
14
|
-
export declare class Ec2SSMConnect extends pulumi.ComponentResource {
|
|
15
|
-
ec2SecurityGroup: aws.ec2.SecurityGroup;
|
|
16
|
-
ssmVpcEndpoint: aws.ec2.VpcEndpoint;
|
|
17
|
-
ec2MessagesVpcEndpoint: aws.ec2.VpcEndpoint;
|
|
18
|
-
ssmMessagesVpcEndpoint: aws.ec2.VpcEndpoint;
|
|
19
|
-
ec2: aws.ec2.Instance;
|
|
20
|
-
constructor(name: string, args: Ec2SSMConnectArgs, opts?: pulumi.ComponentResourceOptions);
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=ec2-ssm-connect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ec2-ssm-connect.d.ts","sourceRoot":"","sources":["../../src/components/ec2-ssm-connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAMnC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KACrC,CAAC,CAAC;CACJ,CAAC;AAEF,qBAAa,aAAc,SAAQ,MAAM,CAAC,iBAAiB;IACzD,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC;IACxC,cAAc,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IACpC,sBAAsB,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IAC5C,sBAAsB,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IAC5C,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAGpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,iBAAiB,EACvB,IAAI,GAAE,MAAM,CAAC,wBAA6B;CAqJ7C"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
-
import * as aws from '@pulumi/aws';
|
|
3
|
-
import { Size } from '../types/size';
|
|
4
|
-
export declare const awsRegion: string;
|
|
5
|
-
export declare const assumeRolePolicy: aws.iam.PolicyDocument;
|
|
6
|
-
export type RoleInlinePolicy = {
|
|
7
|
-
/**
|
|
8
|
-
* Name of the role policy.
|
|
9
|
-
*/
|
|
10
|
-
name?: pulumi.Input<string>;
|
|
11
|
-
/**
|
|
12
|
-
* Policy document as a JSON formatted string.
|
|
13
|
-
*/
|
|
14
|
-
policy?: pulumi.Input<string>;
|
|
15
|
-
};
|
|
16
|
-
export type PersistentStorageMountPoint = {
|
|
17
|
-
sourceVolume: string;
|
|
18
|
-
containerPath: string;
|
|
19
|
-
readOnly?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export type PersistentStorageVolume = {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
export type PersistentStorageConfig = {
|
|
25
|
-
volumes: PersistentStorageVolume[];
|
|
26
|
-
mountPoints: PersistentStorageMountPoint[];
|
|
27
|
-
};
|
|
28
|
-
export type EcsServiceArgs = {
|
|
29
|
-
/**
|
|
30
|
-
* The ECR image used to start a container.
|
|
31
|
-
*/
|
|
32
|
-
image: pulumi.Input<string>;
|
|
33
|
-
/**
|
|
34
|
-
* Exposed service port.
|
|
35
|
-
*/
|
|
36
|
-
port: pulumi.Input<number>;
|
|
37
|
-
/**
|
|
38
|
-
* The aws.ecs.Cluster id.
|
|
39
|
-
*/
|
|
40
|
-
clusterId: pulumi.Input<string>;
|
|
41
|
-
/**
|
|
42
|
-
* The aws.ecs.Cluster name.
|
|
43
|
-
*/
|
|
44
|
-
clusterName: pulumi.Input<string>;
|
|
45
|
-
vpcId: pulumi.Input<string>;
|
|
46
|
-
/**
|
|
47
|
-
* The IPv4 CIDR block for the VPC.
|
|
48
|
-
*/
|
|
49
|
-
vpcCidrBlock: pulumi.Input<string>;
|
|
50
|
-
/**
|
|
51
|
-
* If the `assignPublicIp` parameter is set to `true`, the publicSubnetIds
|
|
52
|
-
* must be provided; otherwise, provide the privateSubnetIds.
|
|
53
|
-
*/
|
|
54
|
-
subnetIds: pulumi.Input<pulumi.Input<string>[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Number of instances of the task definition to place and keep running. Defaults to 1.
|
|
57
|
-
*/
|
|
58
|
-
desiredCount?: pulumi.Input<number>;
|
|
59
|
-
/**
|
|
60
|
-
* CPU and memory size used for running the container. Defaults to "small".
|
|
61
|
-
* Available predefined options are:
|
|
62
|
-
* - small (0.25 vCPU, 0.5 GB memory)
|
|
63
|
-
* - medium (0.5 vCPU, 1 GB memory)
|
|
64
|
-
* - large (1 vCPU memory, 2 GB memory)
|
|
65
|
-
* - xlarge (2 vCPU, 4 GB memory)
|
|
66
|
-
*/
|
|
67
|
-
size?: pulumi.Input<Size>;
|
|
68
|
-
/**
|
|
69
|
-
* The environment variables to pass to a container. Don't use this field for
|
|
70
|
-
* sensitive information such as passwords, API keys, etc. For that purpose,
|
|
71
|
-
* please use the `secrets` property.
|
|
72
|
-
* Defaults to [].
|
|
73
|
-
*/
|
|
74
|
-
environment?: pulumi.Input<aws.ecs.KeyValuePair[]>;
|
|
75
|
-
/**
|
|
76
|
-
* The secrets to pass to the container. Defaults to [].
|
|
77
|
-
*/
|
|
78
|
-
secrets?: pulumi.Input<aws.ecs.Secret[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Enable service auto discovery and assign DNS record to service.
|
|
81
|
-
* Defaults to false.
|
|
82
|
-
*/
|
|
83
|
-
enableServiceAutoDiscovery: pulumi.Input<boolean>;
|
|
84
|
-
/**
|
|
85
|
-
* Configuration for multiple EFS volumes and their mount points.
|
|
86
|
-
* Each mount point specifies a container path where the EFS volume will be mounted.
|
|
87
|
-
*/
|
|
88
|
-
persistentStorageConfig?: pulumi.Input<PersistentStorageConfig>;
|
|
89
|
-
/**
|
|
90
|
-
* Alternate docker CMD instruction.
|
|
91
|
-
*/
|
|
92
|
-
dockerCommand?: pulumi.Input<string[]>;
|
|
93
|
-
/**
|
|
94
|
-
* Autoscaling options for ecs service.
|
|
95
|
-
*/
|
|
96
|
-
autoscaling?: pulumi.Input<{
|
|
97
|
-
/**
|
|
98
|
-
* Is autoscaling enabled or disabled. Defaults to false.
|
|
99
|
-
*/
|
|
100
|
-
enabled: pulumi.Input<boolean>;
|
|
101
|
-
/**
|
|
102
|
-
* Min capacity of the scalable target. Defaults to 1.
|
|
103
|
-
*/
|
|
104
|
-
minCount?: pulumi.Input<number>;
|
|
105
|
-
/**
|
|
106
|
-
* Max capacity of the scalable target. Defaults to 1.
|
|
107
|
-
*/
|
|
108
|
-
maxCount?: pulumi.Input<number>;
|
|
109
|
-
}>;
|
|
110
|
-
lbTargetGroupArn?: aws.lb.TargetGroup['arn'];
|
|
111
|
-
/**
|
|
112
|
-
* Custom service security group
|
|
113
|
-
* In case no security group is provided, default security group will be used.
|
|
114
|
-
*/
|
|
115
|
-
securityGroup?: aws.ec2.SecurityGroup;
|
|
116
|
-
/**
|
|
117
|
-
* Assign public IP address to service.
|
|
118
|
-
*/
|
|
119
|
-
assignPublicIp?: pulumi.Input<boolean>;
|
|
120
|
-
taskExecutionRoleInlinePolicies?: pulumi.Input<pulumi.Input<RoleInlinePolicy>[]>;
|
|
121
|
-
taskRoleInlinePolicies?: pulumi.Input<pulumi.Input<RoleInlinePolicy>[]>;
|
|
122
|
-
/**
|
|
123
|
-
* A map of tags to assign to the resource.
|
|
124
|
-
*/
|
|
125
|
-
tags?: pulumi.Input<{
|
|
126
|
-
[key: string]: pulumi.Input<string>;
|
|
127
|
-
}>;
|
|
128
|
-
};
|
|
129
|
-
export declare class EcsService extends pulumi.ComponentResource {
|
|
130
|
-
name: string;
|
|
131
|
-
logGroup: aws.cloudwatch.LogGroup;
|
|
132
|
-
taskDefinition: aws.ecs.TaskDefinition;
|
|
133
|
-
serviceDiscoveryService?: aws.servicediscovery.Service;
|
|
134
|
-
service: aws.ecs.Service;
|
|
135
|
-
constructor(name: string, args: EcsServiceArgs, opts?: pulumi.ComponentResourceOptions);
|
|
136
|
-
private createLogGroup;
|
|
137
|
-
private createPersistentStorage;
|
|
138
|
-
private createTaskDefinition;
|
|
139
|
-
private createServiceDiscovery;
|
|
140
|
-
private createEcsService;
|
|
141
|
-
private enableAutoscaling;
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=ecs-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ecs-service.d.ts","sourceRoot":"","sources":["../../src/components/ecs-service.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EcsService = exports.assumeRolePolicy = exports.awsRegion = void 0;
|
|
4
|
-
const pulumi = require("@pulumi/pulumi");
|
|
5
|
-
const aws = require("@pulumi/aws");
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const config = new pulumi.Config('aws');
|
|
8
|
-
exports.awsRegion = config.require('region');
|
|
9
|
-
exports.assumeRolePolicy = {
|
|
10
|
-
Version: '2012-10-17',
|
|
11
|
-
Statement: [
|
|
12
|
-
{
|
|
13
|
-
Action: 'sts:AssumeRole',
|
|
14
|
-
Principal: {
|
|
15
|
-
Service: 'ecs-tasks.amazonaws.com',
|
|
16
|
-
},
|
|
17
|
-
Effect: 'Allow',
|
|
18
|
-
Sid: '',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Standard directory permissions:
|
|
24
|
-
* - Owner: read, write, execute (7)
|
|
25
|
-
* - Group: read, execute (5)
|
|
26
|
-
* - Others: read, execute (5)
|
|
27
|
-
*/
|
|
28
|
-
const STANDARD_DIRECTORY_PERMISSIONS = '0755';
|
|
29
|
-
const FIRST_POSIX_NON_ROOT_USER = {
|
|
30
|
-
userId: 1000,
|
|
31
|
-
groupId: 1000,
|
|
32
|
-
permissions: STANDARD_DIRECTORY_PERMISSIONS,
|
|
33
|
-
};
|
|
34
|
-
const defaults = {
|
|
35
|
-
desiredCount: 1,
|
|
36
|
-
size: 'small',
|
|
37
|
-
environment: [],
|
|
38
|
-
secrets: [],
|
|
39
|
-
enableServiceAutoDiscovery: false,
|
|
40
|
-
assignPublicIp: false,
|
|
41
|
-
taskExecutionRoleInlinePolicies: [],
|
|
42
|
-
taskRoleInlinePolicies: [],
|
|
43
|
-
autoscaling: {
|
|
44
|
-
enabled: false,
|
|
45
|
-
minCount: 1,
|
|
46
|
-
maxCount: 1,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
class EcsService extends pulumi.ComponentResource {
|
|
50
|
-
constructor(name, args, opts = {}) {
|
|
51
|
-
const aliases = opts.aliases || [];
|
|
52
|
-
super('studion:ecs:LegacyService', name, {}, Object.assign(Object.assign({}, opts), { aliases: [...aliases, { type: 'studion:ecs:Service' }] }));
|
|
53
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
54
|
-
this.name = name;
|
|
55
|
-
this.logGroup = this.createLogGroup();
|
|
56
|
-
this.taskDefinition = this.createTaskDefinition(args);
|
|
57
|
-
if (argsWithDefaults.enableServiceAutoDiscovery) {
|
|
58
|
-
this.serviceDiscoveryService = this.createServiceDiscovery(argsWithDefaults.vpcId);
|
|
59
|
-
}
|
|
60
|
-
this.service = this.createEcsService(args, opts);
|
|
61
|
-
if (argsWithDefaults.autoscaling.enabled) {
|
|
62
|
-
this.enableAutoscaling(args);
|
|
63
|
-
}
|
|
64
|
-
this.registerOutputs();
|
|
65
|
-
}
|
|
66
|
-
createLogGroup() {
|
|
67
|
-
const logGroup = new aws.cloudwatch.LogGroup(`${this.name}-log-group`, {
|
|
68
|
-
retentionInDays: 14,
|
|
69
|
-
namePrefix: `/ecs/${this.name}-`,
|
|
70
|
-
tags: constants_1.commonTags,
|
|
71
|
-
}, { parent: this });
|
|
72
|
-
return logGroup;
|
|
73
|
-
}
|
|
74
|
-
createPersistentStorage({ vpcId, vpcCidrBlock, subnetIds, }) {
|
|
75
|
-
const efs = new aws.efs.FileSystem(`${this.name}-efs`, {
|
|
76
|
-
encrypted: true,
|
|
77
|
-
lifecyclePolicies: [
|
|
78
|
-
{
|
|
79
|
-
transitionToPrimaryStorageClass: 'AFTER_1_ACCESS',
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
transitionToIa: 'AFTER_7_DAYS',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
performanceMode: 'generalPurpose',
|
|
86
|
-
throughputMode: 'bursting',
|
|
87
|
-
tags: Object.assign(Object.assign({}, constants_1.commonTags), { Name: `${this.name}-data` }),
|
|
88
|
-
}, { parent: this });
|
|
89
|
-
const securityGroup = new aws.ec2.SecurityGroup(`${this.name}-persistent-storage-security-group`, {
|
|
90
|
-
vpcId: vpcId,
|
|
91
|
-
ingress: [
|
|
92
|
-
{
|
|
93
|
-
fromPort: 2049,
|
|
94
|
-
toPort: 2049,
|
|
95
|
-
protocol: 'tcp',
|
|
96
|
-
cidrBlocks: [vpcCidrBlock],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
tags: constants_1.commonTags,
|
|
100
|
-
}, { parent: this });
|
|
101
|
-
pulumi.all([subnetIds]).apply(([ids]) => {
|
|
102
|
-
ids.forEach(it => {
|
|
103
|
-
const mountTarget = new aws.efs.MountTarget(`${this.name}-mount-target-${it}`, {
|
|
104
|
-
fileSystemId: efs.id,
|
|
105
|
-
subnetId: it,
|
|
106
|
-
securityGroups: [securityGroup.id],
|
|
107
|
-
}, { parent: this });
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
return efs;
|
|
111
|
-
}
|
|
112
|
-
createTaskDefinition(args) {
|
|
113
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
114
|
-
const stack = pulumi.getStack();
|
|
115
|
-
const secretManagerSecretsInlinePolicy = {
|
|
116
|
-
name: `${this.name}-secret-manager-access`,
|
|
117
|
-
policy: JSON.stringify({
|
|
118
|
-
Version: '2012-10-17',
|
|
119
|
-
Statement: [
|
|
120
|
-
{
|
|
121
|
-
Sid: 'AllowContainerToGetSecretManagerSecrets',
|
|
122
|
-
Effect: 'Allow',
|
|
123
|
-
Action: ['ssm:GetParameters', 'secretsmanager:GetSecretValue'],
|
|
124
|
-
Resource: '*',
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
}),
|
|
128
|
-
};
|
|
129
|
-
const taskExecutionRole = new aws.iam.Role(`${this.name}-ecs-task-exec-role`, {
|
|
130
|
-
namePrefix: `${this.name}-ecs-task-exec-role-`,
|
|
131
|
-
assumeRolePolicy: exports.assumeRolePolicy,
|
|
132
|
-
managedPolicyArns: [
|
|
133
|
-
'arn:aws:iam::aws:policy/CloudWatchFullAccess',
|
|
134
|
-
'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess',
|
|
135
|
-
],
|
|
136
|
-
inlinePolicies: [
|
|
137
|
-
secretManagerSecretsInlinePolicy,
|
|
138
|
-
...argsWithDefaults.taskExecutionRoleInlinePolicies,
|
|
139
|
-
],
|
|
140
|
-
tags: constants_1.commonTags,
|
|
141
|
-
}, { parent: this });
|
|
142
|
-
const execCmdInlinePolicy = {
|
|
143
|
-
name: `${this.name}-ecs-exec`,
|
|
144
|
-
policy: JSON.stringify({
|
|
145
|
-
Version: '2012-10-17',
|
|
146
|
-
Statement: [
|
|
147
|
-
{
|
|
148
|
-
Sid: 'AllowContainerToCreateECSExecSSMChannel',
|
|
149
|
-
Effect: 'Allow',
|
|
150
|
-
Action: [
|
|
151
|
-
'ssmmessages:CreateControlChannel',
|
|
152
|
-
'ssmmessages:CreateDataChannel',
|
|
153
|
-
'ssmmessages:OpenControlChannel',
|
|
154
|
-
'ssmmessages:OpenDataChannel',
|
|
155
|
-
],
|
|
156
|
-
Resource: '*',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
}),
|
|
160
|
-
};
|
|
161
|
-
const taskRole = new aws.iam.Role(`${this.name}-ecs-task-role`, {
|
|
162
|
-
namePrefix: `${this.name}-ecs-task-role-`,
|
|
163
|
-
assumeRolePolicy: exports.assumeRolePolicy,
|
|
164
|
-
inlinePolicies: [
|
|
165
|
-
execCmdInlinePolicy,
|
|
166
|
-
...argsWithDefaults.taskRoleInlinePolicies,
|
|
167
|
-
],
|
|
168
|
-
tags: constants_1.commonTags,
|
|
169
|
-
}, { parent: this });
|
|
170
|
-
const parsedSize = pulumi.all([argsWithDefaults.size]).apply(([size]) => {
|
|
171
|
-
const mapCapabilities = ({ cpu, memory }) => ({
|
|
172
|
-
cpu: String(cpu),
|
|
173
|
-
memory: String(memory),
|
|
174
|
-
});
|
|
175
|
-
if (typeof size === 'string') {
|
|
176
|
-
return mapCapabilities(constants_1.PredefinedSize[size]);
|
|
177
|
-
}
|
|
178
|
-
if (typeof size === 'object') {
|
|
179
|
-
return mapCapabilities(size);
|
|
180
|
-
}
|
|
181
|
-
throw Error('Incorrect EcsService size argument');
|
|
182
|
-
});
|
|
183
|
-
const fileSystemId = this.createPersistentStorage(argsWithDefaults).id;
|
|
184
|
-
const accessPoint = new aws.efs.AccessPoint(`${this.name}-efs-ap`, {
|
|
185
|
-
fileSystemId,
|
|
186
|
-
posixUser: {
|
|
187
|
-
uid: FIRST_POSIX_NON_ROOT_USER.userId,
|
|
188
|
-
gid: FIRST_POSIX_NON_ROOT_USER.groupId,
|
|
189
|
-
},
|
|
190
|
-
rootDirectory: {
|
|
191
|
-
path: '/data',
|
|
192
|
-
creationInfo: {
|
|
193
|
-
ownerUid: FIRST_POSIX_NON_ROOT_USER.userId,
|
|
194
|
-
ownerGid: FIRST_POSIX_NON_ROOT_USER.groupId,
|
|
195
|
-
permissions: FIRST_POSIX_NON_ROOT_USER.permissions,
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
const taskDefinition = new aws.ecs.TaskDefinition(`${this.name}-task-definition`, Object.assign(Object.assign({ family: `${this.name}-task-definition-${stack}`, networkMode: 'awsvpc', executionRoleArn: taskExecutionRole.arn, taskRoleArn: taskRole.arn, cpu: parsedSize.cpu, memory: parsedSize.memory, requiresCompatibilities: ['FARGATE'], containerDefinitions: pulumi
|
|
200
|
-
.all([
|
|
201
|
-
this.name,
|
|
202
|
-
argsWithDefaults.image,
|
|
203
|
-
argsWithDefaults.port,
|
|
204
|
-
argsWithDefaults.environment,
|
|
205
|
-
argsWithDefaults.secrets,
|
|
206
|
-
argsWithDefaults.persistentStorageConfig,
|
|
207
|
-
argsWithDefaults.dockerCommand,
|
|
208
|
-
this.logGroup.name,
|
|
209
|
-
exports.awsRegion,
|
|
210
|
-
])
|
|
211
|
-
.apply(([containerName, image, port, environment, secrets, persistentStorageConfig, command, logGroup, region,]) => {
|
|
212
|
-
return JSON.stringify([
|
|
213
|
-
Object.assign(Object.assign({ readonlyRootFilesystem: false, name: containerName, image, essential: true, portMappings: [
|
|
214
|
-
{
|
|
215
|
-
containerPort: port,
|
|
216
|
-
protocol: 'tcp',
|
|
217
|
-
},
|
|
218
|
-
] }, (persistentStorageConfig && {
|
|
219
|
-
mountPoints: persistentStorageConfig.mountPoints.map(mountPoint => {
|
|
220
|
-
var _a;
|
|
221
|
-
return ({
|
|
222
|
-
containerPath: mountPoint.containerPath,
|
|
223
|
-
sourceVolume: mountPoint.sourceVolume,
|
|
224
|
-
readOnly: (_a = mountPoint.readOnly) !== null && _a !== void 0 ? _a : false,
|
|
225
|
-
});
|
|
226
|
-
}),
|
|
227
|
-
user: `${FIRST_POSIX_NON_ROOT_USER.userId}:${FIRST_POSIX_NON_ROOT_USER.groupId}`,
|
|
228
|
-
})), { logConfiguration: {
|
|
229
|
-
logDriver: 'awslogs',
|
|
230
|
-
options: {
|
|
231
|
-
'awslogs-group': logGroup,
|
|
232
|
-
'awslogs-region': region,
|
|
233
|
-
'awslogs-stream-prefix': 'ecs',
|
|
234
|
-
},
|
|
235
|
-
}, command,
|
|
236
|
-
environment,
|
|
237
|
-
secrets }),
|
|
238
|
-
]);
|
|
239
|
-
}) }, (argsWithDefaults.persistentStorageConfig && {
|
|
240
|
-
volumes: argsWithDefaults.persistentStorageConfig.volumes.map(volume => ({
|
|
241
|
-
name: volume.name,
|
|
242
|
-
efsVolumeConfiguration: {
|
|
243
|
-
fileSystemId,
|
|
244
|
-
transitEncryption: 'ENABLED',
|
|
245
|
-
authorizationConfig: {
|
|
246
|
-
accessPointId: accessPoint.id,
|
|
247
|
-
iam: 'ENABLED',
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
})),
|
|
251
|
-
})), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this });
|
|
252
|
-
return taskDefinition;
|
|
253
|
-
}
|
|
254
|
-
createServiceDiscovery(vpcId) {
|
|
255
|
-
const privateDnsNamespace = new aws.servicediscovery.PrivateDnsNamespace(`${this.name}-private-dns-namespace`, {
|
|
256
|
-
vpc: vpcId,
|
|
257
|
-
name: this.name,
|
|
258
|
-
tags: constants_1.commonTags,
|
|
259
|
-
}, { parent: this });
|
|
260
|
-
return new aws.servicediscovery.Service(`${this.name}-service-discovery`, {
|
|
261
|
-
name: this.name,
|
|
262
|
-
dnsConfig: {
|
|
263
|
-
namespaceId: privateDnsNamespace.id,
|
|
264
|
-
dnsRecords: [
|
|
265
|
-
{
|
|
266
|
-
ttl: 10,
|
|
267
|
-
type: 'A',
|
|
268
|
-
},
|
|
269
|
-
],
|
|
270
|
-
routingPolicy: 'MULTIVALUE',
|
|
271
|
-
},
|
|
272
|
-
tags: constants_1.commonTags,
|
|
273
|
-
}, { parent: this });
|
|
274
|
-
}
|
|
275
|
-
createEcsService(args, opts) {
|
|
276
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
277
|
-
const securityGroup = argsWithDefaults.securityGroup ||
|
|
278
|
-
new aws.ec2.SecurityGroup(`${this.name}-service-security-group`, {
|
|
279
|
-
vpcId: argsWithDefaults.vpcId,
|
|
280
|
-
ingress: [
|
|
281
|
-
{
|
|
282
|
-
fromPort: 0,
|
|
283
|
-
toPort: 0,
|
|
284
|
-
protocol: '-1',
|
|
285
|
-
cidrBlocks: [argsWithDefaults.vpcCidrBlock],
|
|
286
|
-
},
|
|
287
|
-
],
|
|
288
|
-
egress: [
|
|
289
|
-
{
|
|
290
|
-
fromPort: 0,
|
|
291
|
-
toPort: 0,
|
|
292
|
-
protocol: '-1',
|
|
293
|
-
cidrBlocks: ['0.0.0.0/0'],
|
|
294
|
-
},
|
|
295
|
-
],
|
|
296
|
-
tags: constants_1.commonTags,
|
|
297
|
-
}, { parent: this });
|
|
298
|
-
const service = new aws.ecs.Service(`${this.name}-service`, Object.assign(Object.assign(Object.assign(Object.assign({ name: this.name, cluster: argsWithDefaults.clusterId, launchType: 'FARGATE', desiredCount: argsWithDefaults.desiredCount, taskDefinition: this.taskDefinition.arn, enableExecuteCommand: true }, (argsWithDefaults.lbTargetGroupArn && {
|
|
299
|
-
loadBalancers: [
|
|
300
|
-
{
|
|
301
|
-
containerName: this.name,
|
|
302
|
-
containerPort: argsWithDefaults.port,
|
|
303
|
-
targetGroupArn: argsWithDefaults.lbTargetGroupArn,
|
|
304
|
-
},
|
|
305
|
-
],
|
|
306
|
-
})), { networkConfiguration: {
|
|
307
|
-
assignPublicIp: argsWithDefaults.assignPublicIp,
|
|
308
|
-
subnets: argsWithDefaults.subnetIds,
|
|
309
|
-
securityGroups: [securityGroup.id],
|
|
310
|
-
} }), (argsWithDefaults.enableServiceAutoDiscovery &&
|
|
311
|
-
this.serviceDiscoveryService && {
|
|
312
|
-
serviceRegistries: {
|
|
313
|
-
registryArn: this.serviceDiscoveryService.arn,
|
|
314
|
-
},
|
|
315
|
-
})), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), {
|
|
316
|
-
parent: this,
|
|
317
|
-
dependsOn: opts.dependsOn,
|
|
318
|
-
});
|
|
319
|
-
return service;
|
|
320
|
-
}
|
|
321
|
-
enableAutoscaling(args) {
|
|
322
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
323
|
-
const autoscalingTarget = new aws.appautoscaling.Target(`${this.name}-autoscale-target`, {
|
|
324
|
-
minCapacity: argsWithDefaults.autoscaling.minCount,
|
|
325
|
-
maxCapacity: argsWithDefaults.autoscaling.maxCount,
|
|
326
|
-
resourceId: pulumi.interpolate `service/${argsWithDefaults.clusterName}/${this.service.name}`,
|
|
327
|
-
serviceNamespace: 'ecs',
|
|
328
|
-
scalableDimension: 'ecs:service:DesiredCount',
|
|
329
|
-
tags: constants_1.commonTags,
|
|
330
|
-
}, { parent: this });
|
|
331
|
-
const memoryAutoscalingPolicy = new aws.appautoscaling.Policy(`${this.name}-memory-autoscale-policy`, {
|
|
332
|
-
policyType: 'TargetTrackingScaling',
|
|
333
|
-
resourceId: autoscalingTarget.resourceId,
|
|
334
|
-
scalableDimension: autoscalingTarget.scalableDimension,
|
|
335
|
-
serviceNamespace: autoscalingTarget.serviceNamespace,
|
|
336
|
-
targetTrackingScalingPolicyConfiguration: {
|
|
337
|
-
predefinedMetricSpecification: {
|
|
338
|
-
predefinedMetricType: 'ECSServiceAverageMemoryUtilization',
|
|
339
|
-
},
|
|
340
|
-
targetValue: 70,
|
|
341
|
-
},
|
|
342
|
-
}, { parent: this });
|
|
343
|
-
const cpuAutoscalingPolicy = new aws.appautoscaling.Policy(`${this.name}-cpu-autoscale-policy`, {
|
|
344
|
-
policyType: 'TargetTrackingScaling',
|
|
345
|
-
resourceId: autoscalingTarget.resourceId,
|
|
346
|
-
scalableDimension: autoscalingTarget.scalableDimension,
|
|
347
|
-
serviceNamespace: autoscalingTarget.serviceNamespace,
|
|
348
|
-
targetTrackingScalingPolicyConfiguration: {
|
|
349
|
-
predefinedMetricSpecification: {
|
|
350
|
-
predefinedMetricType: 'ECSServiceAverageCPUUtilization',
|
|
351
|
-
},
|
|
352
|
-
targetValue: 70,
|
|
353
|
-
},
|
|
354
|
-
}, { parent: this });
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
exports.EcsService = EcsService;
|