konokenj.cdk-api-mcp-server 0.25.0__py3-none-any.whl → 0.27.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-amplify-alpha/README.md +14 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-alpha/README.md +608 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.model-schema-additional-items.ts +72 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront/README.md +8 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront/integ.distribution-basic.ts +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-config.ts +15 -4
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-group.ts +40 -218
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/README.md +34 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-ec2-deploy-ssm-managed.ts +140 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-ec2-deploy.ts +140 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/README.md +55 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.machine-image-cached.ts +53 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.volume-initialization-rate.ts +21 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +16 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.availability-zone-rebalancing.ts +4 -14
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts +29 -35
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.exec-command.ts +22 -16
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.lb-awsvpc-nw.ts +16 -26
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts +8 -18
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/README.md +6 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/integ.custom-addons.ts +48 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/README.md +1 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.expose-metric-with-dimensions.ts +47 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.gp3.ts +16 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.https.ts +54 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/README.md +25 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-serverless-v2-autopause.ts +27 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.instance-from-cluster-snapshot.ts +23 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ssm/README.md +16 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/README.md +21 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.map-jsonata-itemselector.ts +36 -0
- 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 +104 -102
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/README.md +23 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-dryrun-update.ts +32 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary.ts +2 -0
- {konokenj_cdk_api_mcp_server-0.25.0.dist-info → konokenj_cdk_api_mcp_server-0.27.0.dist-info}/METADATA +1 -1
- {konokenj_cdk_api_mcp_server-0.25.0.dist-info → konokenj_cdk_api_mcp_server-0.27.0.dist-info}/RECORD +43 -30
- {konokenj_cdk_api_mcp_server-0.25.0.dist-info → konokenj_cdk_api_mcp_server-0.27.0.dist-info}/WHEEL +0 -0
- {konokenj_cdk_api_mcp_server-0.25.0.dist-info → konokenj_cdk_api_mcp_server-0.27.0.dist-info}/entry_points.txt +0 -0
- {konokenj_cdk_api_mcp_server-0.25.0.dist-info → konokenj_cdk_api_mcp_server-0.27.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as codepipeline from 'aws-cdk-lib/aws-codepipeline';
|
|
2
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
3
|
+
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
|
|
4
|
+
import * as targets from 'aws-cdk-lib/aws-elasticloadbalancingv2-targets';
|
|
5
|
+
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
6
|
+
import * as s3deployment from 'aws-cdk-lib/aws-s3-deployment';
|
|
7
|
+
import * as cdk from 'aws-cdk-lib';
|
|
8
|
+
import * as cpactions from 'aws-cdk-lib/aws-codepipeline-actions';
|
|
9
|
+
import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
|
|
12
|
+
const app = new cdk.App();
|
|
13
|
+
|
|
14
|
+
const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-ec2-deploy');
|
|
15
|
+
|
|
16
|
+
const vpc = new ec2.Vpc(stack, 'VPC', {
|
|
17
|
+
maxAzs: 2,
|
|
18
|
+
natGateways: 0,
|
|
19
|
+
restrictDefaultSecurityGroup: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const instances = Object.fromEntries(Object.entries({ NoLB: [0, 1], LB: [0, 1] }).map(([tagValue, indexs]) => {
|
|
23
|
+
const innerInstances = indexs.map((index) => {
|
|
24
|
+
const userData = ec2.UserData.forLinux();
|
|
25
|
+
userData.addCommands('dnf install httpd -y', 'mkdir -p /var/www/html', 'touch /var/www/html/index.html', 'systemctl start httpd');
|
|
26
|
+
const instance = new ec2.Instance(stack, `Instance-${tagValue}-${index}`, {
|
|
27
|
+
vpc,
|
|
28
|
+
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
|
|
29
|
+
availabilityZone: vpc.publicSubnets[index].availabilityZone,
|
|
30
|
+
machineImage: ec2.MachineImage.latestAmazonLinux2023({ cpuType: ec2.AmazonLinuxCpuType.ARM_64 }),
|
|
31
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE4_GRAVITON, ec2.InstanceSize.MICRO),
|
|
32
|
+
ssmSessionPermissions: true,
|
|
33
|
+
userData,
|
|
34
|
+
});
|
|
35
|
+
instance.applyRemovalPolicy(cdk.RemovalPolicy.DESTROY);
|
|
36
|
+
instance.connections.allowFromAnyIpv4(ec2.Port.HTTP);
|
|
37
|
+
cdk.Tags.of(instance).add('EC2-Target', tagValue);
|
|
38
|
+
return instance;
|
|
39
|
+
});
|
|
40
|
+
return [tagValue, innerInstances];
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const alb = new elbv2.ApplicationLoadBalancer(stack, 'ALB', { vpc, internetFacing: true });
|
|
44
|
+
const albTg = new elbv2.ApplicationTargetGroup(stack, 'ALB-TG', {
|
|
45
|
+
vpc,
|
|
46
|
+
protocol: elbv2.ApplicationProtocol.HTTP,
|
|
47
|
+
deregistrationDelay: cdk.Duration.seconds(0),
|
|
48
|
+
});
|
|
49
|
+
alb.addListener('HTTP', {
|
|
50
|
+
protocol: elbv2.ApplicationProtocol.HTTP,
|
|
51
|
+
defaultTargetGroups: [albTg],
|
|
52
|
+
});
|
|
53
|
+
alb.connections.allowToAnyIpv4(ec2.Port.HTTP);
|
|
54
|
+
albTg.addTarget(...instances.LB.map((instance) => new targets.InstanceTarget(instance)));
|
|
55
|
+
|
|
56
|
+
const bucket = new s3.Bucket(stack, 'ArtifactBucket', {
|
|
57
|
+
versioned: true,
|
|
58
|
+
autoDeleteObjects: true,
|
|
59
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
60
|
+
});
|
|
61
|
+
instances.LB.forEach((instance) => bucket.grantRead(instance));
|
|
62
|
+
instances.NoLB.forEach((instance) => bucket.grantRead(instance));
|
|
63
|
+
const deployment = new s3deployment.BucketDeployment(stack, 'ArtifactDeployment', {
|
|
64
|
+
destinationBucket: bucket,
|
|
65
|
+
sources: [s3deployment.Source.asset(path.join(__dirname, 'ec2-deploy-artifacts', 'inline'))],
|
|
66
|
+
extract: false,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const sourceArtifact = new codepipeline.Artifact('SourceArtifact');
|
|
70
|
+
const sourceAction = new cpactions.S3SourceAction({
|
|
71
|
+
actionName: 'Source',
|
|
72
|
+
output: sourceArtifact,
|
|
73
|
+
bucket,
|
|
74
|
+
bucketKey: cdk.Fn.select(0, deployment.objectKeys),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const pipeline = new codepipeline.Pipeline(stack, 'MyPipeline', {
|
|
78
|
+
pipelineType: codepipeline.PipelineType.V2,
|
|
79
|
+
artifactBucket: bucket,
|
|
80
|
+
stages: [
|
|
81
|
+
{
|
|
82
|
+
stageName: 'Source',
|
|
83
|
+
actions: [sourceAction],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
stageName: 'Deploy',
|
|
87
|
+
actions: [
|
|
88
|
+
new cpactions.Ec2DeployAction({
|
|
89
|
+
actionName: 'EC2-NoLB',
|
|
90
|
+
input: sourceArtifact,
|
|
91
|
+
instanceType: cpactions.Ec2InstanceType.EC2,
|
|
92
|
+
instanceTagKey: 'EC2-Target',
|
|
93
|
+
instanceTagValue: 'NoLB',
|
|
94
|
+
deploySpecifications: cpactions.Ec2DeploySpecifications.inline({
|
|
95
|
+
targetDirectory: '/var/www/html/NoLB',
|
|
96
|
+
preScript: 'scripts/pre-deploy.sh',
|
|
97
|
+
postScript: 'scripts/post-deploy.sh',
|
|
98
|
+
}),
|
|
99
|
+
maxBatch: cpactions.Ec2MaxInstances.targets(2),
|
|
100
|
+
}),
|
|
101
|
+
new cpactions.Ec2DeployAction({
|
|
102
|
+
actionName: 'EC2-LB',
|
|
103
|
+
input: sourceArtifact,
|
|
104
|
+
instanceType: cpactions.Ec2InstanceType.EC2,
|
|
105
|
+
instanceTagKey: 'EC2-Target',
|
|
106
|
+
instanceTagValue: 'LB',
|
|
107
|
+
deploySpecifications: cpactions.Ec2DeploySpecifications.inline({
|
|
108
|
+
targetDirectory: '/var/www/html/LB',
|
|
109
|
+
preScript: 'scripts/pre-deploy.sh',
|
|
110
|
+
postScript: 'scripts/post-deploy.sh',
|
|
111
|
+
}),
|
|
112
|
+
targetGroups: [albTg],
|
|
113
|
+
maxBatch: cpactions.Ec2MaxInstances.targets(1),
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const integ = new IntegTest(app, 'ec2-deploy-action-integ', {
|
|
121
|
+
testCases: [stack],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const pipelineExecutionId = integ.assertions
|
|
125
|
+
.awsApiCall('codepipeline', 'StartPipelineExecution', { name: pipeline.pipelineName })
|
|
126
|
+
.getAttString('pipelineExecutionId');
|
|
127
|
+
const waitPipelieneSuccess = integ.assertions
|
|
128
|
+
.awsApiCall('codepipeline', 'GetPipelineExecution', { pipelineName: pipeline.pipelineName, pipelineExecutionId })
|
|
129
|
+
.waitForAssertions({ interval: cdk.Duration.seconds(30) })
|
|
130
|
+
.expect(ExpectedResult.objectLike({ pipelineExecution: { status: 'Succeeded' } }));
|
|
131
|
+
waitPipelieneSuccess.next(
|
|
132
|
+
integ.assertions
|
|
133
|
+
.httpApiCall(`http://${alb.loadBalancerDnsName}/LB/index.html`)
|
|
134
|
+
.expect(ExpectedResult.objectLike({ status: 200 })),
|
|
135
|
+
);
|
|
136
|
+
instances.NoLB.forEach((instance) => waitPipelieneSuccess.next(
|
|
137
|
+
integ.assertions
|
|
138
|
+
.httpApiCall(`http://${instance.instancePublicDnsName}/NoLB/index.html`)
|
|
139
|
+
.expect(ExpectedResult.objectLike({ status: 200 })),
|
|
140
|
+
));
|
|
@@ -882,7 +882,10 @@ If the security group ID is known and configuration details are unknown, use met
|
|
|
882
882
|
const sg = ec2.SecurityGroup.fromLookupById(this, 'SecurityGroupLookup', 'sg-1234');
|
|
883
883
|
```
|
|
884
884
|
|
|
885
|
-
The result of `SecurityGroup.fromLookupByName` and `SecurityGroup.fromLookupById` operations will be
|
|
885
|
+
The result of `SecurityGroup.fromLookupByName` and `SecurityGroup.fromLookupById` operations will be
|
|
886
|
+
written to a file called `cdk.context.json`.
|
|
887
|
+
You must commit this file to source control so that the lookup values are available in non-privileged
|
|
888
|
+
environments such as CI build steps, and to ensure your template builds are repeatable.
|
|
886
889
|
|
|
887
890
|
### Cross Stack Connections
|
|
888
891
|
|
|
@@ -969,6 +972,13 @@ examples of images you might want to use:
|
|
|
969
972
|
> `cdk.context.json`, or use the `cdk context` command. For more information, see
|
|
970
973
|
> [Runtime Context](https://docs.aws.amazon.com/cdk/latest/guide/context.html) in the CDK
|
|
971
974
|
> developer guide.
|
|
975
|
+
>
|
|
976
|
+
> To customize the cache key, use the `additionalCacheKey` parameter.
|
|
977
|
+
> This allows you to have multiple lookups with the same parameters
|
|
978
|
+
> cache their values separately. This can be useful if you want to
|
|
979
|
+
> scope the context variable to a construct (ie, using `additionalCacheKey: this.node.path`),
|
|
980
|
+
> so that if the value in the cache needs to be updated, it does not need to be updated
|
|
981
|
+
> for all constructs at the same time.
|
|
972
982
|
>
|
|
973
983
|
> `MachineImage.genericLinux()`, `MachineImage.genericWindows()` will use `CfnMapping` in
|
|
974
984
|
> an agnostic stack.
|
|
@@ -1361,6 +1371,31 @@ new ec2.Instance(this, 'LatestAl2023', {
|
|
|
1361
1371
|
// context cache is turned on by default
|
|
1362
1372
|
machineImage: new ec2.AmazonLinux2023ImageSsmParameter(),
|
|
1363
1373
|
});
|
|
1374
|
+
|
|
1375
|
+
// or
|
|
1376
|
+
new ec2.Instance(this, 'LatestAl2023', {
|
|
1377
|
+
vpc,
|
|
1378
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE),
|
|
1379
|
+
machineImage: ec2.MachineImage.latestAmazonLinux2023({
|
|
1380
|
+
cachedInContext: true,
|
|
1381
|
+
// creates a distinct context variable for this image, instead of resolving to the same
|
|
1382
|
+
// value anywhere this lookup is done in your app
|
|
1383
|
+
additionalCacheKey: this.node.path,
|
|
1384
|
+
}),
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1387
|
+
// or
|
|
1388
|
+
new ec2.Instance(this, 'LatestAl2023', {
|
|
1389
|
+
vpc,
|
|
1390
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE),
|
|
1391
|
+
// context cache is turned on by default
|
|
1392
|
+
machineImage: new ec2.AmazonLinux2023ImageSsmParameter({
|
|
1393
|
+
// creates a distinct context variable for this image, instead of resolving to the same
|
|
1394
|
+
// value anywhere this lookup is done in your app
|
|
1395
|
+
additionalCacheKey: this.node.path,
|
|
1396
|
+
}),
|
|
1397
|
+
});
|
|
1398
|
+
|
|
1364
1399
|
```
|
|
1365
1400
|
|
|
1366
1401
|
#### Kernel Versions
|
|
@@ -1843,6 +1878,25 @@ new ec2.Volume(this, 'Volume', {
|
|
|
1843
1878
|
});
|
|
1844
1879
|
```
|
|
1845
1880
|
|
|
1881
|
+
#### Volume initialization rate
|
|
1882
|
+
|
|
1883
|
+
When creating an EBS volume from a snapshot, you can specify the [volume initialization rate](https://docs.aws.amazon.com/ebs/latest/userguide/initalize-volume.html#volume-initialization-rate) at which the snapshot blocks are downloaded from Amazon S3 to the volume.
|
|
1884
|
+
Specifying a volume initialization rate ensures that the volume is initialized at a predictable and consistent rate after creation.
|
|
1885
|
+
|
|
1886
|
+
```ts
|
|
1887
|
+
new ec2.Volume(this, 'Volume', {
|
|
1888
|
+
availabilityZone: 'us-east-1a',
|
|
1889
|
+
size: Size.gibibytes(500),
|
|
1890
|
+
snapshotId: 'snap-1234567890abcdef0',
|
|
1891
|
+
volumeInitializationRate: Size.mebibytes(250),
|
|
1892
|
+
});
|
|
1893
|
+
```
|
|
1894
|
+
|
|
1895
|
+
The `volumeInitializationRate` must be:
|
|
1896
|
+
|
|
1897
|
+
* Between 100 and 300 MiB/s
|
|
1898
|
+
* Only specified when creating a volume from a snapshot
|
|
1899
|
+
|
|
1846
1900
|
### Configuring Instance Metadata Service (IMDS)
|
|
1847
1901
|
|
|
1848
1902
|
#### Toggling IMDSv1
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.machine-image-cached.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
2
|
+
import {
|
|
3
|
+
Stack,
|
|
4
|
+
StackProps,
|
|
5
|
+
App,
|
|
6
|
+
aws_ec2 as ec2,
|
|
7
|
+
} from 'aws-cdk-lib';
|
|
8
|
+
import { Construct } from 'constructs';
|
|
9
|
+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
|
|
10
|
+
|
|
11
|
+
// we associate this stack with an explicit environment since this is required by the
|
|
12
|
+
// environmental context provider used with `cachedInContext`. CDK_INTEG_XXX are set
|
|
13
|
+
// when producing the .expected file and CDK_DEFAULT_XXX is passed in through from
|
|
14
|
+
// the CLI in actual deployment.
|
|
15
|
+
const env = {
|
|
16
|
+
account: process.env.CDK_INTEG_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT,
|
|
17
|
+
region: process.env.CDK_INTEG_REGION || process.env.CDK_DEFAULT_REGION,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export class TestCase extends Stack {
|
|
21
|
+
constructor(scope: Construct, id: string, props?: StackProps) {
|
|
22
|
+
super(scope, id, props);
|
|
23
|
+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
|
|
24
|
+
const vpc = new ec2.Vpc(this, 'Vpc');
|
|
25
|
+
|
|
26
|
+
const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.NANO);
|
|
27
|
+
|
|
28
|
+
new ec2.Instance(this, 'al2023Cached', {
|
|
29
|
+
instanceType,
|
|
30
|
+
machineImage: ec2.MachineImage.latestAmazonLinux2023({
|
|
31
|
+
cachedInContext: true,
|
|
32
|
+
}),
|
|
33
|
+
vpc,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
new ec2.Instance(this, 'al2023CachedScope', {
|
|
37
|
+
instanceType,
|
|
38
|
+
machineImage: ec2.MachineImage.latestAmazonLinux2023({
|
|
39
|
+
cachedInContext: true,
|
|
40
|
+
additionalCacheKey: 'extraKey',
|
|
41
|
+
}),
|
|
42
|
+
vpc,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const app = new App();
|
|
48
|
+
const stack = new TestCase(app, 'cdk-ec2-machine-image-cached', { env });
|
|
49
|
+
new IntegTest(app, 'integ-ec2-machine-image-cached', {
|
|
50
|
+
testCases: [stack],
|
|
51
|
+
enableLookups: true,
|
|
52
|
+
});
|
|
53
|
+
app.synth();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
3
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
4
|
+
|
|
5
|
+
const app = new cdk.App();
|
|
6
|
+
|
|
7
|
+
const stack = new cdk.Stack(app, 'volume-initialization-rate-stack');
|
|
8
|
+
|
|
9
|
+
const snapshotId = process.env.SNAPSHOT_ID ?? 'snap-123456789abcdef0';
|
|
10
|
+
|
|
11
|
+
new ec2.Volume(stack, 'Volume', {
|
|
12
|
+
availabilityZone: 'us-east-1a',
|
|
13
|
+
size: cdk.Size.gibibytes(1),
|
|
14
|
+
volumeType: ec2.EbsDeviceVolumeType.GP3,
|
|
15
|
+
volumeInitializationRate: cdk.Size.mebibytes(100),
|
|
16
|
+
snapshotId,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
new integ.IntegTest(app, 'volume-initialization-rate-integ', {
|
|
20
|
+
testCases: [stack],
|
|
21
|
+
});
|
|
@@ -169,6 +169,22 @@ const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
|
|
|
169
169
|
});
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
+
To customize the cache key, use the `additionalCacheKey` parameter.
|
|
173
|
+
This allows you to have multiple lookups with the same parameters
|
|
174
|
+
cache their values separately. This can be useful if you want to
|
|
175
|
+
scope the context variable to a construct (ie, using `additionalCacheKey: this.node.path`),
|
|
176
|
+
so that if the value in the cache needs to be updated, it does not need to be updated
|
|
177
|
+
for all constructs at the same time.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
declare const vpc: ec2.Vpc;
|
|
181
|
+
const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
|
|
182
|
+
machineImage: ecs.EcsOptimizedImage.amazonLinux({ cachedInContext: true, additionalCacheKey: this.node.path }),
|
|
183
|
+
vpc,
|
|
184
|
+
instanceType: new ec2.InstanceType('t2.micro'),
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
172
188
|
To use `LaunchTemplate` with `AsgCapacityProvider`, make sure to specify the `userData` in the `LaunchTemplate`:
|
|
173
189
|
|
|
174
190
|
```ts
|
|
@@ -3,30 +3,20 @@ 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(
|
|
7
|
-
postCliContext: {
|
|
8
|
-
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
9
|
-
'@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy': false,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
6
|
+
const app = new cdk.App();
|
|
12
7
|
const stack = new cdk.Stack(app, 'aws-ecs-integ-availability-zone-rebalancing');
|
|
13
8
|
|
|
14
9
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
15
10
|
|
|
16
|
-
const cluster = new ecs.Cluster(stack, '
|
|
17
|
-
|
|
18
|
-
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
19
|
-
instanceType: new ec2.InstanceType('t2.micro'),
|
|
20
|
-
});
|
|
11
|
+
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
|
|
21
12
|
|
|
22
|
-
const taskDefinition = new ecs.
|
|
13
|
+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef');
|
|
23
14
|
|
|
24
15
|
taskDefinition.addContainer('web', {
|
|
25
16
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
26
|
-
memoryLimitMiB: 256,
|
|
27
17
|
});
|
|
28
18
|
|
|
29
|
-
new ecs.
|
|
19
|
+
new ecs.FargateService(stack, 'FargateService', {
|
|
30
20
|
cluster,
|
|
31
21
|
taskDefinition,
|
|
32
22
|
availabilityZoneRebalancing: ecs.AvailabilityZoneRebalancing.ENABLED,
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts
CHANGED
|
@@ -1,53 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import * as autoscaling from 'aws-cdk-lib/aws-autoscaling';
|
|
3
|
-
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
4
1
|
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import * as kms from 'aws-cdk-lib/aws-kms';
|
|
3
|
+
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
5
4
|
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,
|
|
12
11
|
'@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,
|
|
16
12
|
},
|
|
17
13
|
});
|
|
18
14
|
const stack = new cdk.Stack(app, 'aws-ecs-integ-enable-execute-command');
|
|
19
15
|
|
|
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
|
-
});
|
|
16
|
+
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
35
17
|
|
|
36
|
-
const
|
|
18
|
+
const kmsKey = new kms.Key(stack, 'KmsKey');
|
|
37
19
|
|
|
38
|
-
const
|
|
39
|
-
|
|
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,
|
|
20
|
+
const execBucket = new s3.Bucket(stack, 'EcsExecBucket', {
|
|
21
|
+
encryptionKey: kmsKey,
|
|
46
22
|
});
|
|
47
23
|
|
|
48
|
-
const cluster = new ecs.Cluster(stack, '
|
|
24
|
+
const cluster = new ecs.Cluster(stack, 'FargateCluster', {
|
|
49
25
|
vpc,
|
|
50
26
|
executeCommandConfiguration: {
|
|
27
|
+
kmsKey,
|
|
51
28
|
logConfiguration: {
|
|
52
29
|
s3Bucket: execBucket,
|
|
53
30
|
s3EncryptionEnabled: true,
|
|
@@ -56,9 +33,19 @@ const cluster = new ecs.Cluster(stack, 'EC2CPCluster', {
|
|
|
56
33
|
logging: ecs.ExecuteCommandLogging.OVERRIDE,
|
|
57
34
|
},
|
|
58
35
|
});
|
|
59
|
-
cluster.addAsgCapacityProvider(cp);
|
|
60
36
|
|
|
61
|
-
new ecs.
|
|
37
|
+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef');
|
|
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', {
|
|
62
49
|
cluster,
|
|
63
50
|
taskDefinition,
|
|
64
51
|
enableExecuteCommand: true,
|
|
@@ -66,5 +53,12 @@ new ecs.Ec2Service(stack, 'EC2Service', {
|
|
|
66
53
|
|
|
67
54
|
new integ.IntegTest(app, 'enable-execute-command-test', {
|
|
68
55
|
testCases: [stack],
|
|
56
|
+
diffAssets: true,
|
|
57
|
+
cdkCommandOptions: {
|
|
58
|
+
deploy: {
|
|
59
|
+
args: {
|
|
60
|
+
rollback: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
69
64
|
});
|
|
70
|
-
app.synth();
|
|
@@ -3,16 +3,11 @@ 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';
|
|
6
8
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
7
9
|
|
|
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
|
-
});
|
|
10
|
+
const app = new cdk.App();
|
|
16
11
|
const stack = new cdk.Stack(app, 'aws-ecs-integ-exec-command');
|
|
17
12
|
|
|
18
13
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
@@ -27,7 +22,7 @@ const execBucket = new s3.Bucket(stack, 'EcsExecBucket', {
|
|
|
27
22
|
encryptionKey: kmsKey,
|
|
28
23
|
});
|
|
29
24
|
|
|
30
|
-
const cluster = new ecs.Cluster(stack, '
|
|
25
|
+
const cluster = new ecs.Cluster(stack, 'FargateCluster', {
|
|
31
26
|
vpc,
|
|
32
27
|
executeCommandConfiguration: {
|
|
33
28
|
kmsKey,
|
|
@@ -41,21 +36,32 @@ const cluster = new ecs.Cluster(stack, 'Ec2Cluster', {
|
|
|
41
36
|
logging: ecs.ExecuteCommandLogging.OVERRIDE,
|
|
42
37
|
},
|
|
43
38
|
});
|
|
44
|
-
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
45
|
-
instanceType: new ec2.InstanceType('t2.micro'),
|
|
46
|
-
});
|
|
47
39
|
|
|
48
|
-
const taskDefinition = new ecs.
|
|
40
|
+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef');
|
|
49
41
|
|
|
50
42
|
taskDefinition.addContainer('web', {
|
|
51
43
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
52
|
-
|
|
44
|
+
healthCheck: {
|
|
45
|
+
command: ['CMD-SHELL', 'curl localhost:8000'],
|
|
46
|
+
interval: Duration.seconds(60),
|
|
47
|
+
timeout: Duration.seconds(40),
|
|
48
|
+
},
|
|
53
49
|
});
|
|
54
50
|
|
|
55
|
-
new ecs.
|
|
51
|
+
new ecs.FargateService(stack, 'FargateService', {
|
|
56
52
|
cluster,
|
|
57
53
|
taskDefinition,
|
|
58
54
|
enableExecuteCommand: true,
|
|
59
55
|
});
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
new integ.IntegTest(app, 'exec-command-integ-test', {
|
|
58
|
+
testCases: [stack],
|
|
59
|
+
diffAssets: true,
|
|
60
|
+
cdkCommandOptions: {
|
|
61
|
+
deploy: {
|
|
62
|
+
args: {
|
|
63
|
+
rollback: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -3,48 +3,38 @@ 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(
|
|
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
|
-
});
|
|
6
|
+
const app = new cdk.App();
|
|
14
7
|
const stack = new cdk.Stack(app, 'aws-ecs-integ');
|
|
15
8
|
|
|
16
9
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
17
10
|
|
|
18
|
-
const cluster = new ecs.Cluster(stack, '
|
|
19
|
-
cluster.addCapacity('DefaultAutoScalingGroup', {
|
|
20
|
-
instanceType: new ec2.InstanceType('t2.micro'),
|
|
21
|
-
});
|
|
11
|
+
const cluster = new ecs.Cluster(stack, 'FargateCluster', { vpc });
|
|
22
12
|
|
|
23
|
-
const taskDefinition = new ecs.
|
|
24
|
-
|
|
13
|
+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', {
|
|
14
|
+
memoryLimitMiB: 1024,
|
|
15
|
+
cpu: 512,
|
|
25
16
|
});
|
|
26
17
|
|
|
27
|
-
|
|
18
|
+
taskDefinition.addContainer('web', {
|
|
28
19
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
20
|
+
portMappings: [{
|
|
21
|
+
containerPort: 80,
|
|
22
|
+
protocol: ecs.Protocol.TCP,
|
|
23
|
+
}],
|
|
33
24
|
});
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
containerPort: 80,
|
|
37
|
-
protocol: ecs.Protocol.TCP,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const service = new ecs.Ec2Service(stack, 'Service', {
|
|
26
|
+
const service = new ecs.FargateService(stack, 'Service', {
|
|
41
27
|
cluster,
|
|
42
28
|
taskDefinition,
|
|
43
29
|
});
|
|
44
30
|
|
|
31
|
+
const scaling = service.autoScaleTaskCount({ maxCapacity: 10 });
|
|
32
|
+
// Quite low to try and force it to scale
|
|
33
|
+
scaling.scaleOnCpuUtilization('ReasonableCpu', { targetUtilizationPercent: 10 });
|
|
34
|
+
|
|
45
35
|
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc, internetFacing: true });
|
|
46
36
|
const listener = lb.addListener('PublicListener', { port: 80, open: true });
|
|
47
|
-
listener.addTargets('
|
|
37
|
+
listener.addTargets('Fargate', {
|
|
48
38
|
port: 80,
|
|
49
39
|
targets: [service],
|
|
50
40
|
});
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts
CHANGED
|
@@ -3,35 +3,25 @@ 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
|
-
|
|
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');
|
|
6
|
+
const app = new cdk.App();
|
|
7
|
+
const stack = new cdk.Stack(app, 'integ-pseudo-terminal');
|
|
15
8
|
|
|
16
9
|
// Create a cluster
|
|
17
10
|
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
|
|
18
11
|
|
|
19
12
|
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', {
|
|
25
|
-
networkMode: ecs.NetworkMode.AWS_VPC,
|
|
13
|
+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', {
|
|
14
|
+
cpu: 256,
|
|
15
|
+
memoryLimitMiB: 512,
|
|
26
16
|
});
|
|
27
|
-
|
|
28
17
|
taskDefinition.addContainer('web', {
|
|
29
18
|
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
|
|
30
|
-
memoryLimitMiB:
|
|
19
|
+
memoryLimitMiB: 512,
|
|
20
|
+
cpu: 256,
|
|
31
21
|
pseudoTerminal: true,
|
|
32
22
|
});
|
|
33
23
|
|
|
34
|
-
new ecs.
|
|
24
|
+
new ecs.FargateService(stack, 'Service', {
|
|
35
25
|
cluster,
|
|
36
26
|
taskDefinition,
|
|
37
27
|
});
|
|
@@ -1106,6 +1106,12 @@ new eks.Cluster(this, 'Cluster', {
|
|
|
1106
1106
|
});
|
|
1107
1107
|
```
|
|
1108
1108
|
|
|
1109
|
+
### Self-Managed Add-ons
|
|
1110
|
+
|
|
1111
|
+
Amazon EKS automatically installs self-managed add-ons such as the Amazon VPC CNI plugin for Kubernetes, kube-proxy, and CoreDNS for every cluster. You can change the default configuration of the add-ons and update them when desired. If you wish to create a cluster without the default add-ons, set `bootstrapSelfManagedAddons` as `false`. When this is set to false, make sure to install the necessary alternatives which provide functionality that enables pod and service operations for your EKS cluster.
|
|
1112
|
+
|
|
1113
|
+
> Changing the value of `bootstrapSelfManagedAddons` after the EKS cluster creation will result in a replacement of the cluster.
|
|
1114
|
+
|
|
1109
1115
|
## Permissions and Security
|
|
1110
1116
|
|
|
1111
1117
|
Amazon EKS provides several mechanism of securing the cluster and granting permissions to specific IAM users and roles.
|