konokenj.cdk-api-mcp-server 0.45.0__py3-none-any.whl → 0.47.0__py3-none-any.whl
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.
Potentially problematic release.
This version of konokenj.cdk-api-mcp-server might be problematic. Click here for more details.
- cdk_api_mcp_server/__about__.py +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-elasticache-alpha/README.md +421 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/custom-resource-handlers/README.md +15 -78
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/README.md +14 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.http-origin.ts +5 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-config.ts +4 -15
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-group.ts +218 -40
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/README.md +24 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/integ.cluster-serverless.ts +34 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.availability-zone-rebalancing.ts +14 -4
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts +35 -29
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.exec-command.ts +16 -22
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.lb-awsvpc-nw.ts +26 -16
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts +18 -8
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-jsonata.ts +80 -87
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke.ts +69 -87
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.start-job-run.ts +43 -96
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/README.md +4 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/integ.newpipeline-reduce-stagerole-scope.ts +4 -1
- {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/METADATA +2 -2
- {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/RECORD +24 -22
- {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/WHEEL +0 -0
- {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/entry_points.txt +0 -0
- {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/licenses/LICENSE.txt +0 -0
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-group.ts
CHANGED
|
@@ -1,62 +1,240 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
1
|
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
|
|
3
|
-
import * as
|
|
2
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
3
|
+
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
4
|
+
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
|
|
4
5
|
import * as cdk from 'aws-cdk-lib';
|
|
6
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
5
7
|
import * as codedeploy from 'aws-cdk-lib/aws-codedeploy';
|
|
6
|
-
import { STANDARD_NODEJS_RUNTIME } from '../../../config';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Follow these instructions to manually test running a CodeDeploy deployment with the resources provisioned in this stack:
|
|
11
|
+
*
|
|
12
|
+
* 1. Deploy the stack:
|
|
13
|
+
```
|
|
14
|
+
$ cdk deploy --app 'node integ.deployment-group.js' aws-cdk-codedeploy-ecs-dg
|
|
15
|
+
```
|
|
16
|
+
*
|
|
17
|
+
* 2. Create a file called `appspec.json` with the following contents, replacing the placeholders with output values from the deployed stack:
|
|
18
|
+
```
|
|
19
|
+
{
|
|
20
|
+
"version": 0.0,
|
|
21
|
+
"Resources": [
|
|
22
|
+
{
|
|
23
|
+
"TargetService": {
|
|
24
|
+
"Type": "AWS::ECS::Service",
|
|
25
|
+
"Properties": {
|
|
26
|
+
"TaskDefinition": "<PLACEHOLDER - NEW TASK DEFINITION>",
|
|
27
|
+
"LoadBalancerInfo": {
|
|
28
|
+
"ContainerName": "Container",
|
|
29
|
+
"ContainerPort": 80
|
|
30
|
+
},
|
|
31
|
+
"PlatformVersion": "LATEST",
|
|
32
|
+
"NetworkConfiguration": {
|
|
33
|
+
"awsvpcConfiguration": {
|
|
34
|
+
"subnets": [
|
|
35
|
+
"<PLACEHOLDER - SUBNET 1 ID>",
|
|
36
|
+
"<PLACEHOLDER - SUBNET 2 ID>",
|
|
37
|
+
],
|
|
38
|
+
"securityGroups": [
|
|
39
|
+
"<PLACEHOLDER - SECURITY GROUP ID>"
|
|
40
|
+
],
|
|
41
|
+
"assignPublicIp": "DISABLED"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
*
|
|
51
|
+
* 3. Start the deployment:
|
|
52
|
+
```
|
|
53
|
+
$ appspec=$(jq -R -s '.' < appspec.json | sed 's/\\n//g')
|
|
54
|
+
$ aws deploy create-deployment \
|
|
55
|
+
--application-name <PLACEHOLDER - CODEDEPLOY APPLICATION NAME> \
|
|
56
|
+
--deployment-group-name <PLACEHOLDER - CODEDEPLOY DEPLOYMENT GROUP NAME> \
|
|
57
|
+
--description "AWS CDK integ test" \
|
|
58
|
+
--revision revisionType=AppSpecContent,appSpecContent={content="$appspec"}
|
|
59
|
+
```
|
|
60
|
+
*
|
|
61
|
+
* 4. Wait for the deployment to complete successfully, providing the deployment ID from the previous step:
|
|
62
|
+
```
|
|
63
|
+
$ aws deploy wait deployment-successful --deployment-id <PLACEHOLDER - DEPLOYMENT ID>
|
|
64
|
+
```
|
|
65
|
+
*
|
|
66
|
+
* 5. Destroy the stack:
|
|
67
|
+
```
|
|
68
|
+
$ cdk destroy --app 'node integ.deployment-group.js' aws-cdk-codedeploy-ecs-dg
|
|
69
|
+
```
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
const app = new cdk.App();
|
|
73
|
+
const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-ecs-dg');
|
|
74
|
+
|
|
75
|
+
// Network infrastructure
|
|
76
|
+
const vpc = new ec2.Vpc(stack, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
77
|
+
|
|
78
|
+
// ECS service
|
|
79
|
+
const cluster = new ecs.Cluster(stack, 'EcsCluster', {
|
|
80
|
+
vpc,
|
|
81
|
+
});
|
|
82
|
+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef');
|
|
83
|
+
taskDefinition.addContainer('Container', {
|
|
84
|
+
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest'),
|
|
85
|
+
portMappings: [{ containerPort: 80 }],
|
|
86
|
+
});
|
|
87
|
+
const service = new ecs.FargateService(stack, 'FargateService', {
|
|
88
|
+
cluster,
|
|
89
|
+
taskDefinition,
|
|
90
|
+
deploymentController: {
|
|
91
|
+
type: ecs.DeploymentControllerType.CODE_DEPLOY,
|
|
11
92
|
},
|
|
12
93
|
});
|
|
13
|
-
const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-lambda');
|
|
14
94
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
95
|
+
// A second task definition for testing a CodeDeploy deployment of the ECS service to a new task definition
|
|
96
|
+
const taskDefinition2 = new ecs.FargateTaskDefinition(stack, 'TaskDef2');
|
|
97
|
+
taskDefinition2.addContainer('Container', {
|
|
98
|
+
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest'),
|
|
99
|
+
portMappings: [{ containerPort: 80 }],
|
|
19
100
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
101
|
+
service.node.addDependency(taskDefinition2);
|
|
102
|
+
|
|
103
|
+
// Load balancer
|
|
104
|
+
const loadBalancer = new elbv2.ApplicationLoadBalancer(stack, 'ServiceLB', {
|
|
105
|
+
vpc,
|
|
106
|
+
internetFacing: false,
|
|
24
107
|
});
|
|
25
108
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
109
|
+
// Listeners
|
|
110
|
+
const prodListener = loadBalancer.addListener('ProdListener', {
|
|
111
|
+
port: 80, // port for production traffic
|
|
112
|
+
protocol: elbv2.ApplicationProtocol.HTTP,
|
|
30
113
|
});
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
runtime: STANDARD_NODEJS_RUNTIME,
|
|
114
|
+
const testListener = loadBalancer.addListener('TestListener', {
|
|
115
|
+
port: 9002, // port for testing
|
|
116
|
+
protocol: elbv2.ApplicationProtocol.HTTP,
|
|
35
117
|
});
|
|
36
118
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
metric: blueGreenAlias.metricErrors(),
|
|
119
|
+
// Target groups
|
|
120
|
+
const blueTG = prodListener.addTargets('BlueTG', {
|
|
121
|
+
port: 80,
|
|
122
|
+
protocol: elbv2.ApplicationProtocol.HTTP,
|
|
123
|
+
targets: [
|
|
124
|
+
service.loadBalancerTarget({
|
|
125
|
+
containerName: 'Container',
|
|
126
|
+
containerPort: 80,
|
|
46
127
|
}),
|
|
47
128
|
],
|
|
48
|
-
|
|
49
|
-
|
|
129
|
+
deregistrationDelay: cdk.Duration.seconds(30),
|
|
130
|
+
healthCheck: {
|
|
131
|
+
interval: cdk.Duration.seconds(5),
|
|
132
|
+
healthyHttpCodes: '200',
|
|
133
|
+
healthyThresholdCount: 2,
|
|
134
|
+
unhealthyThresholdCount: 3,
|
|
135
|
+
timeout: cdk.Duration.seconds(4),
|
|
136
|
+
},
|
|
50
137
|
});
|
|
51
138
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
139
|
+
const greenTG = new elbv2.ApplicationTargetGroup(stack, 'GreenTG', {
|
|
140
|
+
vpc,
|
|
141
|
+
port: 80,
|
|
142
|
+
protocol: elbv2.ApplicationProtocol.HTTP,
|
|
143
|
+
targetType: elbv2.TargetType.IP,
|
|
144
|
+
deregistrationDelay: cdk.Duration.seconds(30),
|
|
145
|
+
healthCheck: {
|
|
146
|
+
interval: cdk.Duration.seconds(5),
|
|
147
|
+
healthyHttpCodes: '200',
|
|
148
|
+
healthyThresholdCount: 2,
|
|
149
|
+
unhealthyThresholdCount: 3,
|
|
150
|
+
timeout: cdk.Duration.seconds(4),
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
testListener.addTargetGroups('GreenTGTest', {
|
|
155
|
+
targetGroups: [greenTG],
|
|
55
156
|
});
|
|
56
157
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
158
|
+
prodListener.node.addDependency(greenTG);
|
|
159
|
+
testListener.node.addDependency(blueTG);
|
|
160
|
+
service.node.addDependency(testListener);
|
|
161
|
+
service.node.addDependency(greenTG);
|
|
162
|
+
|
|
163
|
+
// Alarms: monitor 500s and unhealthy hosts on target groups
|
|
164
|
+
const blueUnhealthyHosts = new cloudwatch.Alarm(stack, 'BlueUnhealthyHosts', {
|
|
165
|
+
alarmName: stack.stackName + '-Unhealthy-Hosts-Blue',
|
|
166
|
+
metric: blueTG.metricUnhealthyHostCount(),
|
|
167
|
+
threshold: 1,
|
|
168
|
+
evaluationPeriods: 2,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const blueApiFailure = new cloudwatch.Alarm(stack, 'Blue5xx', {
|
|
172
|
+
alarmName: stack.stackName + '-Http-500-Blue',
|
|
173
|
+
metric: blueTG.metricHttpCodeTarget(
|
|
174
|
+
elbv2.HttpCodeTarget.TARGET_5XX_COUNT,
|
|
175
|
+
{ period: cdk.Duration.minutes(1) },
|
|
176
|
+
),
|
|
177
|
+
threshold: 1,
|
|
178
|
+
evaluationPeriods: 1,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const greenUnhealthyHosts = new cloudwatch.Alarm(stack, 'GreenUnhealthyHosts', {
|
|
182
|
+
alarmName: stack.stackName + '-Unhealthy-Hosts-Green',
|
|
183
|
+
metric: greenTG.metricUnhealthyHostCount(),
|
|
184
|
+
threshold: 1,
|
|
185
|
+
evaluationPeriods: 2,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const greenApiFailure = new cloudwatch.Alarm(stack, 'Green5xx', {
|
|
189
|
+
alarmName: stack.stackName + '-Http-500-Green',
|
|
190
|
+
metric: greenTG.metricHttpCodeTarget(
|
|
191
|
+
elbv2.HttpCodeTarget.TARGET_5XX_COUNT,
|
|
192
|
+
{ period: cdk.Duration.minutes(1) },
|
|
193
|
+
),
|
|
194
|
+
threshold: 1,
|
|
195
|
+
evaluationPeriods: 1,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Deployment group
|
|
199
|
+
const deploymentConfig = new codedeploy.EcsDeploymentConfig(stack, 'CanaryConfig', {
|
|
200
|
+
trafficRouting: codedeploy.TrafficRouting.timeBasedCanary({
|
|
201
|
+
interval: cdk.Duration.minutes(1),
|
|
202
|
+
percentage: 20,
|
|
203
|
+
}),
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const dg = new codedeploy.EcsDeploymentGroup(stack, 'BlueGreenDG', {
|
|
207
|
+
alarms: [
|
|
208
|
+
blueUnhealthyHosts,
|
|
209
|
+
blueApiFailure,
|
|
210
|
+
greenUnhealthyHosts,
|
|
211
|
+
greenApiFailure,
|
|
212
|
+
],
|
|
213
|
+
service,
|
|
214
|
+
blueGreenDeploymentConfig: {
|
|
215
|
+
blueTargetGroup: blueTG,
|
|
216
|
+
greenTargetGroup: greenTG,
|
|
217
|
+
listener: prodListener,
|
|
218
|
+
testListener,
|
|
219
|
+
terminationWaitTime: cdk.Duration.minutes(1),
|
|
220
|
+
},
|
|
221
|
+
deploymentConfig,
|
|
222
|
+
autoRollback: {
|
|
223
|
+
stoppedDeployment: true,
|
|
224
|
+
},
|
|
225
|
+
ignoreAlarmConfiguration: true,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// Outputs to use for manual testing
|
|
229
|
+
new cdk.CfnOutput(stack, 'NewTaskDefinition', { value: taskDefinition2.taskDefinitionArn });
|
|
230
|
+
new cdk.CfnOutput(stack, 'Subnet1Id', { value: vpc.privateSubnets[0].subnetId });
|
|
231
|
+
new cdk.CfnOutput(stack, 'Subnet2Id', { value: vpc.privateSubnets[1].subnetId });
|
|
232
|
+
new cdk.CfnOutput(stack, 'SecurityGroupId', { value: service.connections.securityGroups[0].securityGroupId });
|
|
233
|
+
new cdk.CfnOutput(stack, 'CodeDeployApplicationName', { value: dg.application.applicationName });
|
|
234
|
+
new cdk.CfnOutput(stack, 'CodeDeployDeploymentGroupName', { value: dg.deploymentGroupName });
|
|
235
|
+
|
|
236
|
+
new integ.IntegTest(app, 'EcsDeploymentGroupTest', {
|
|
237
|
+
testCases: [stack],
|
|
60
238
|
});
|
|
61
239
|
|
|
62
240
|
app.synth();
|
|
@@ -28,6 +28,28 @@ By default, the master password will be generated and stored in AWS Secrets Mana
|
|
|
28
28
|
|
|
29
29
|
Your cluster will be empty by default.
|
|
30
30
|
|
|
31
|
+
## Serverless Clusters
|
|
32
|
+
|
|
33
|
+
DocumentDB supports serverless clusters that automatically scale capacity based on your application's needs.
|
|
34
|
+
To create a serverless cluster, specify the `serverlessV2ScalingConfiguration` instead of `instanceType`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
declare const vpc: ec2.Vpc;
|
|
38
|
+
const cluster = new docdb.DatabaseCluster(this, 'Database', {
|
|
39
|
+
masterUser: {
|
|
40
|
+
username: 'myuser',
|
|
41
|
+
},
|
|
42
|
+
vpc,
|
|
43
|
+
serverlessV2ScalingConfiguration: {
|
|
44
|
+
minCapacity: 0.5,
|
|
45
|
+
maxCapacity: 2,
|
|
46
|
+
},
|
|
47
|
+
engineVersion: '5.0.0', // Serverless requires engine version 5.0.0 or higher
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Note**: DocumentDB serverless requires engine version 5.0.0 or higher and is not compatible with all features. See the [AWS documentation](https://docs.aws.amazon.com/documentdb/latest/developerguide/docdb-serverless-limitations.html) for limitations.
|
|
52
|
+
|
|
31
53
|
## Connecting
|
|
32
54
|
|
|
33
55
|
To control who can access the cluster, use the `.connections` attribute. DocumentDB databases have a default port, so
|
|
@@ -278,3 +300,5 @@ const cluster = new docdb.DatabaseCluster(this, 'Database', {
|
|
|
278
300
|
```
|
|
279
301
|
|
|
280
302
|
**Note**: `StorageType.IOPT1` is supported starting with engine version 5.0.0.
|
|
303
|
+
|
|
304
|
+
**Note**: For serverless clusters, storage type is managed automatically and cannot be specified.
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/integ.cluster-serverless.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import * as cdk from 'aws-cdk-lib';
|
|
3
|
+
import * as constructs from 'constructs';
|
|
4
|
+
import { DatabaseCluster } from 'aws-cdk-lib/aws-docdb';
|
|
5
|
+
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
6
|
+
|
|
7
|
+
class TestStack extends cdk.Stack {
|
|
8
|
+
constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) {
|
|
9
|
+
super(scope, id, props);
|
|
10
|
+
|
|
11
|
+
const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
12
|
+
|
|
13
|
+
new DatabaseCluster(this, 'Database', {
|
|
14
|
+
masterUser: {
|
|
15
|
+
username: 'docdb',
|
|
16
|
+
},
|
|
17
|
+
vpc,
|
|
18
|
+
serverlessV2ScalingConfiguration: {
|
|
19
|
+
minCapacity: 0.5,
|
|
20
|
+
maxCapacity: 2,
|
|
21
|
+
},
|
|
22
|
+
engineVersion: '5.0.0',
|
|
23
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const app = new cdk.App();
|
|
29
|
+
|
|
30
|
+
const stack = new TestStack(app, 'aws-cdk-docdb-cluster-serverless');
|
|
31
|
+
|
|
32
|
+
new IntegTest(app, 'aws-cdk-docdb-cluster-serverless-integ', {
|
|
33
|
+
testCases: [stack],
|
|
34
|
+
});
|
|
@@ -3,20 +3,30 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
3
3
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
4
4
|
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
5
5
|
|
|
6
|
-
const app = new cdk.App(
|
|
6
|
+
const app = new cdk.App({
|
|
7
|
+
postCliContext: {
|
|
8
|
+
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
9
|
+
'@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy': false,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
7
12
|
const stack = new cdk.Stack(app, 'aws-ecs-integ-availability-zone-rebalancing');
|
|
8
13
|
|
|
9
14
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
10
15
|
|
|
11
|
-
const cluster = new ecs.Cluster(stack, '
|
|
16
|
+
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
|
|
17
|
+
|
|
18
|
+
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
19
|
+
instanceType: new ec2.InstanceType('t2.micro'),
|
|
20
|
+
});
|
|
12
21
|
|
|
13
|
-
const taskDefinition = new ecs.
|
|
22
|
+
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef');
|
|
14
23
|
|
|
15
24
|
taskDefinition.addContainer('web', {
|
|
16
25
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
26
|
+
memoryLimitMiB: 256,
|
|
17
27
|
});
|
|
18
28
|
|
|
19
|
-
new ecs.
|
|
29
|
+
new ecs.Ec2Service(stack, 'FrontendService', {
|
|
20
30
|
cluster,
|
|
21
31
|
taskDefinition,
|
|
22
32
|
availabilityZoneRebalancing: ecs.AvailabilityZoneRebalancing.ENABLED,
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts
CHANGED
|
@@ -1,30 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
1
|
+
|
|
2
|
+
import * as autoscaling from 'aws-cdk-lib/aws-autoscaling';
|
|
3
3
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
4
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
4
5
|
import * as cdk from 'aws-cdk-lib';
|
|
5
|
-
import { Duration } from 'aws-cdk-lib';
|
|
6
6
|
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
7
7
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
8
8
|
|
|
9
9
|
const app = new cdk.App({
|
|
10
10
|
postCliContext: {
|
|
11
|
+
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
11
12
|
'@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions': true,
|
|
13
|
+
'@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature': false,
|
|
14
|
+
'@aws-cdk/aws-ecs:disableEcsImdsBlocking': false,
|
|
15
|
+
'@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy': false,
|
|
12
16
|
},
|
|
13
17
|
});
|
|
14
18
|
const stack = new cdk.Stack(app, 'aws-ecs-integ-enable-execute-command');
|
|
15
19
|
|
|
16
|
-
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2
|
|
20
|
+
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });
|
|
21
|
+
|
|
22
|
+
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef');
|
|
23
|
+
|
|
24
|
+
taskDefinition.addContainer('web', {
|
|
25
|
+
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
26
|
+
memoryReservationMiB: 256,
|
|
27
|
+
portMappings: [
|
|
28
|
+
{
|
|
29
|
+
containerPort: 80,
|
|
30
|
+
hostPort: 8080,
|
|
31
|
+
protocol: ecs.Protocol.TCP,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
17
35
|
|
|
18
|
-
const
|
|
36
|
+
const execBucket = new s3.Bucket(stack, 'EcsExecBucket');
|
|
19
37
|
|
|
20
|
-
const
|
|
21
|
-
|
|
38
|
+
const cp = new ecs.AsgCapacityProvider(stack, 'EC2CapacityProvider', {
|
|
39
|
+
autoScalingGroup: new autoscaling.AutoScalingGroup(stack, 'ASG', {
|
|
40
|
+
vpc,
|
|
41
|
+
instanceType: new ec2.InstanceType('t2.micro'),
|
|
42
|
+
machineImage: ecs.EcsOptimizedImage.amazonLinux2(),
|
|
43
|
+
}),
|
|
44
|
+
// This is to allow cdk destroy to work; otherwise deletion will hang bc ASG cannot be deleted
|
|
45
|
+
enableManagedTerminationProtection: false,
|
|
22
46
|
});
|
|
23
47
|
|
|
24
|
-
const cluster = new ecs.Cluster(stack, '
|
|
48
|
+
const cluster = new ecs.Cluster(stack, 'EC2CPCluster', {
|
|
25
49
|
vpc,
|
|
26
50
|
executeCommandConfiguration: {
|
|
27
|
-
kmsKey,
|
|
28
51
|
logConfiguration: {
|
|
29
52
|
s3Bucket: execBucket,
|
|
30
53
|
s3EncryptionEnabled: true,
|
|
@@ -33,19 +56,9 @@ const cluster = new ecs.Cluster(stack, 'FargateCluster', {
|
|
|
33
56
|
logging: ecs.ExecuteCommandLogging.OVERRIDE,
|
|
34
57
|
},
|
|
35
58
|
});
|
|
59
|
+
cluster.addAsgCapacityProvider(cp);
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
taskDefinition.addContainer('web', {
|
|
40
|
-
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
41
|
-
healthCheck: {
|
|
42
|
-
command: ['CMD-SHELL', 'curl localhost:8000'],
|
|
43
|
-
interval: Duration.seconds(60),
|
|
44
|
-
timeout: Duration.seconds(40),
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
new ecs.FargateService(stack, 'FargateService', {
|
|
61
|
+
new ecs.Ec2Service(stack, 'EC2Service', {
|
|
49
62
|
cluster,
|
|
50
63
|
taskDefinition,
|
|
51
64
|
enableExecuteCommand: true,
|
|
@@ -53,12 +66,5 @@ new ecs.FargateService(stack, 'FargateService', {
|
|
|
53
66
|
|
|
54
67
|
new integ.IntegTest(app, 'enable-execute-command-test', {
|
|
55
68
|
testCases: [stack],
|
|
56
|
-
diffAssets: true,
|
|
57
|
-
cdkCommandOptions: {
|
|
58
|
-
deploy: {
|
|
59
|
-
args: {
|
|
60
|
-
rollback: true,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
69
|
});
|
|
70
|
+
app.synth();
|
|
@@ -3,11 +3,16 @@ import * as kms from 'aws-cdk-lib/aws-kms';
|
|
|
3
3
|
import * as logs from 'aws-cdk-lib/aws-logs';
|
|
4
4
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
5
5
|
import * as cdk from 'aws-cdk-lib';
|
|
6
|
-
import { Duration } from 'aws-cdk-lib';
|
|
7
|
-
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
8
6
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
9
7
|
|
|
10
|
-
const app = new cdk.App(
|
|
8
|
+
const app = new cdk.App({
|
|
9
|
+
postCliContext: {
|
|
10
|
+
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
11
|
+
'@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature': false,
|
|
12
|
+
'@aws-cdk/aws-ecs:disableEcsImdsBlocking': false,
|
|
13
|
+
'@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy': false,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
11
16
|
const stack = new cdk.Stack(app, 'aws-ecs-integ-exec-command');
|
|
12
17
|
|
|
13
18
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
@@ -22,7 +27,7 @@ const execBucket = new s3.Bucket(stack, 'EcsExecBucket', {
|
|
|
22
27
|
encryptionKey: kmsKey,
|
|
23
28
|
});
|
|
24
29
|
|
|
25
|
-
const cluster = new ecs.Cluster(stack, '
|
|
30
|
+
const cluster = new ecs.Cluster(stack, 'Ec2Cluster', {
|
|
26
31
|
vpc,
|
|
27
32
|
executeCommandConfiguration: {
|
|
28
33
|
kmsKey,
|
|
@@ -36,32 +41,21 @@ const cluster = new ecs.Cluster(stack, 'FargateCluster', {
|
|
|
36
41
|
logging: ecs.ExecuteCommandLogging.OVERRIDE,
|
|
37
42
|
},
|
|
38
43
|
});
|
|
44
|
+
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
45
|
+
instanceType: new ec2.InstanceType('t2.micro'),
|
|
46
|
+
});
|
|
39
47
|
|
|
40
|
-
const taskDefinition = new ecs.
|
|
48
|
+
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef');
|
|
41
49
|
|
|
42
50
|
taskDefinition.addContainer('web', {
|
|
43
51
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
44
|
-
|
|
45
|
-
command: ['CMD-SHELL', 'curl localhost:8000'],
|
|
46
|
-
interval: Duration.seconds(60),
|
|
47
|
-
timeout: Duration.seconds(40),
|
|
48
|
-
},
|
|
52
|
+
memoryLimitMiB: 256,
|
|
49
53
|
});
|
|
50
54
|
|
|
51
|
-
new ecs.
|
|
55
|
+
new ecs.Ec2Service(stack, 'Ec2Service', {
|
|
52
56
|
cluster,
|
|
53
57
|
taskDefinition,
|
|
54
58
|
enableExecuteCommand: true,
|
|
55
59
|
});
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
testCases: [stack],
|
|
59
|
-
diffAssets: true,
|
|
60
|
-
cdkCommandOptions: {
|
|
61
|
-
deploy: {
|
|
62
|
-
args: {
|
|
63
|
-
rollback: true,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
});
|
|
61
|
+
app.synth();
|
|
@@ -3,38 +3,48 @@ import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
|
|
|
3
3
|
import * as cdk from 'aws-cdk-lib';
|
|
4
4
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
5
5
|
|
|
6
|
-
const app = new cdk.App(
|
|
6
|
+
const app = new cdk.App({
|
|
7
|
+
postCliContext: {
|
|
8
|
+
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
9
|
+
'@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature': false,
|
|
10
|
+
'@aws-cdk/aws-ecs:disableEcsImdsBlocking': false,
|
|
11
|
+
'@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy': false,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
7
14
|
const stack = new cdk.Stack(app, 'aws-ecs-integ');
|
|
8
15
|
|
|
9
16
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
10
17
|
|
|
11
|
-
const cluster = new ecs.Cluster(stack, '
|
|
18
|
+
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
|
|
19
|
+
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
20
|
+
instanceType: new ec2.InstanceType('t2.micro'),
|
|
21
|
+
});
|
|
12
22
|
|
|
13
|
-
const taskDefinition = new ecs.
|
|
14
|
-
|
|
15
|
-
cpu: 512,
|
|
23
|
+
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', {
|
|
24
|
+
networkMode: ecs.NetworkMode.AWS_VPC,
|
|
16
25
|
});
|
|
17
26
|
|
|
18
|
-
taskDefinition.addContainer('web', {
|
|
27
|
+
const container = taskDefinition.addContainer('web', {
|
|
19
28
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
29
|
+
memoryLimitMiB: 256,
|
|
30
|
+
environment: {
|
|
31
|
+
SOME_VARIABLE: 'value',
|
|
32
|
+
},
|
|
24
33
|
});
|
|
25
34
|
|
|
26
|
-
|
|
35
|
+
container.addPortMappings({
|
|
36
|
+
containerPort: 80,
|
|
37
|
+
protocol: ecs.Protocol.TCP,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const service = new ecs.Ec2Service(stack, 'Service', {
|
|
27
41
|
cluster,
|
|
28
42
|
taskDefinition,
|
|
29
43
|
});
|
|
30
44
|
|
|
31
|
-
const scaling = service.autoScaleTaskCount({ maxCapacity: 10 });
|
|
32
|
-
// Quite low to try and force it to scale
|
|
33
|
-
scaling.scaleOnCpuUtilization('ReasonableCpu', { targetUtilizationPercent: 10 });
|
|
34
|
-
|
|
35
45
|
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc, internetFacing: true });
|
|
36
46
|
const listener = lb.addListener('PublicListener', { port: 80, open: true });
|
|
37
|
-
listener.addTargets('
|
|
47
|
+
listener.addTargets('ECS', {
|
|
38
48
|
port: 80,
|
|
39
49
|
targets: [service],
|
|
40
50
|
});
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts
CHANGED
|
@@ -3,25 +3,35 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
3
3
|
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
4
4
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
5
5
|
|
|
6
|
-
const app = new cdk.App(
|
|
7
|
-
|
|
6
|
+
const app = new cdk.App({
|
|
7
|
+
postCliContext: {
|
|
8
|
+
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
9
|
+
'@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature': false,
|
|
10
|
+
'@aws-cdk/aws-ecs:disableEcsImdsBlocking': false,
|
|
11
|
+
'@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy': false,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const stack = new cdk.Stack(app, 'aws-ecs-integ-pseudo-terminal');
|
|
8
15
|
|
|
9
16
|
// Create a cluster
|
|
10
17
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
11
18
|
|
|
12
19
|
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
21
|
+
instanceType: new ec2.InstanceType('t2.micro'),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', {
|
|
25
|
+
networkMode: ecs.NetworkMode.AWS_VPC,
|
|
16
26
|
});
|
|
27
|
+
|
|
17
28
|
taskDefinition.addContainer('web', {
|
|
18
29
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
19
|
-
memoryLimitMiB:
|
|
20
|
-
cpu: 256,
|
|
30
|
+
memoryLimitMiB: 256,
|
|
21
31
|
pseudoTerminal: true,
|
|
22
32
|
});
|
|
23
33
|
|
|
24
|
-
new ecs.
|
|
34
|
+
new ecs.Ec2Service(stack, 'Service', {
|
|
25
35
|
cluster,
|
|
26
36
|
taskDefinition,
|
|
27
37
|
});
|