konokenj.cdk-api-mcp-server 0.47.0__py3-none-any.whl → 0.49.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.
- cdk_api_mcp_server/__about__.py +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-amplify-alpha/README.md +12 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/README.md/README.md +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-batch/README.md +15 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-batch/integ.managed-compute-environment-default-instance-class.ts +20 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/README.md +33 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.function-url-origin-ip-address-type.ts +84 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/README.md +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/integ.anomaly-detection-alarm.ts +44 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/README.md +76 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-fleet-attribute-based-compute.ts +59 -7
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-fleet-custom-instance-type.ts +130 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-fleet-overflow-behavior.ts +61 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/README.md +15 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.client-vpn-endpoint-disconnect-on-session-timeout.ts +65 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +101 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.managedinstances-capacity-provider.ts +112 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/README.md +20 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/integ.eks-cluster-removal-policy.ts +31 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesis/README.md +42 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesis/integ.stream-shard-level-monitoring.ts +47 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/README.md +9 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/README.md +4 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.metricfilter-apply-on-transformed-logs.ts +29 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.min.ts +1 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/README.md +12 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.private-hosted-zone-from-attributes.ts +41 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/README.md +17 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-runtime-validation.ts +43 -0
- {konokenj_cdk_api_mcp_server-0.47.0.dist-info → konokenj_cdk_api_mcp_server-0.49.0.dist-info}/METADATA +2 -2
- {konokenj_cdk_api_mcp_server-0.47.0.dist-info → konokenj_cdk_api_mcp_server-0.49.0.dist-info}/RECORD +34 -23
- {konokenj_cdk_api_mcp_server-0.47.0.dist-info → konokenj_cdk_api_mcp_server-0.49.0.dist-info}/WHEEL +0 -0
- {konokenj_cdk_api_mcp_server-0.47.0.dist-info → konokenj_cdk_api_mcp_server-0.49.0.dist-info}/entry_points.txt +0 -0
- {konokenj_cdk_api_mcp_server-0.47.0.dist-info → konokenj_cdk_api_mcp_server-0.49.0.dist-info}/licenses/LICENSE.txt +0 -0
cdk_api_mcp_server/__about__.py
CHANGED
|
@@ -353,6 +353,18 @@ const amplifyApp = new amplify.App(this, 'MyApp', {
|
|
|
353
353
|
});
|
|
354
354
|
```
|
|
355
355
|
|
|
356
|
+
## Build Compute Type
|
|
357
|
+
|
|
358
|
+
You can specify the build compute type by setting the `buildComputeType` property.
|
|
359
|
+
|
|
360
|
+
For more information, see [Configuring the build instance for an Amplify application](https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-instance.html).
|
|
361
|
+
|
|
362
|
+
```ts
|
|
363
|
+
const amplifyApp = new amplify.App(this, 'MyApp', {
|
|
364
|
+
buildComputeType: amplify.BuildComputeType.LARGE_16GB,
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
356
368
|
## Deploying Assets
|
|
357
369
|
|
|
358
370
|
`sourceCodeProvider` is optional; when this is not specified the Amplify app can be deployed to using `.zip` packages. The `asset` property can be used to deploy S3 assets to Amplify as part of the CDK:
|
|
@@ -1059,7 +1059,7 @@ The properties passed to the level 2 constructs `AutoScalingGroup` and `Instance
|
|
|
1059
1059
|
`aws-ec2` module abstract what is passed into the `CfnOption` properties `resourceSignal` and
|
|
1060
1060
|
`autoScalingCreationPolicy`, but when using level 1 constructs you can specify these yourself.
|
|
1061
1061
|
|
|
1062
|
-
The CfnWaitCondition resource from the `aws-cloudformation` module
|
|
1062
|
+
The CfnWaitCondition resource from the `aws-cloudformation` module supports the `resourceSignal`.
|
|
1063
1063
|
The format of the timeout is `PT#H#M#S`. In the example below AWS Cloudformation will wait for
|
|
1064
1064
|
3 success signals to occur within 15 minutes before the status of the resource will be set to
|
|
1065
1065
|
`CREATE_COMPLETE`.
|
|
@@ -65,7 +65,18 @@ For stateful or otherwise non-interruption-tolerant workflows, omit `spot` or se
|
|
|
65
65
|
|
|
66
66
|
#### Choosing Your Instance Types
|
|
67
67
|
|
|
68
|
-
Batch allows you to choose
|
|
68
|
+
Batch allows you to choose most up-to-date instance classes based on your region.
|
|
69
|
+
This example configures your `ComputeEnvironment` to use only ARM64 instance:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const vpc = new ec2.Vpc(this, 'VPC');
|
|
73
|
+
|
|
74
|
+
new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
|
|
75
|
+
vpc,
|
|
76
|
+
defaultInstanceClasses: [batch.DefaultInstanceClass.ARM64],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
69
80
|
This example configures your `ComputeEnvironment` to use only the `M5AD.large` instance:
|
|
70
81
|
|
|
71
82
|
```ts
|
|
@@ -91,6 +102,9 @@ new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
|
|
|
91
102
|
});
|
|
92
103
|
```
|
|
93
104
|
|
|
105
|
+
> [!WARNING]
|
|
106
|
+
> `useOptimalInstanceClasses` is deprecated! Use `defaultInstanceClasses` instead.
|
|
107
|
+
|
|
94
108
|
Unless you explicitly specify `useOptimalInstanceClasses: false`, this compute environment will use `'optimal'` instances,
|
|
95
109
|
which tells Batch to pick an instance from the C4, M4, and R4 instance families.
|
|
96
110
|
*Note*: Batch does not allow specifying instance types or classes with different architectures.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import { App, Stack } from 'aws-cdk-lib';
|
|
3
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
4
|
+
import { ManagedEc2EcsComputeEnvironment, EcsMachineImageType, DefaultInstanceClass } from 'aws-cdk-lib/aws-batch';
|
|
5
|
+
|
|
6
|
+
const app = new App();
|
|
7
|
+
const stack = new Stack(app, 'managed-compute-environment-default-instance-class');
|
|
8
|
+
const vpc = new ec2.Vpc(stack, 'vpc', { restrictDefaultSecurityGroup: false });
|
|
9
|
+
|
|
10
|
+
new ManagedEc2EcsComputeEnvironment(stack, 'ECS', {
|
|
11
|
+
vpc,
|
|
12
|
+
images: [{
|
|
13
|
+
imageType: EcsMachineImageType.ECS_AL2023,
|
|
14
|
+
}],
|
|
15
|
+
defaultInstanceClasses: [DefaultInstanceClass.ARM64],
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
new integ.IntegTest(app, 'integ-managed-compute-environment-default-instance-class', {
|
|
19
|
+
testCases: [stack],
|
|
20
|
+
});
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/README.md
CHANGED
|
@@ -851,6 +851,39 @@ new cloudfront.Distribution(this, 'Distribution', {
|
|
|
851
851
|
});
|
|
852
852
|
```
|
|
853
853
|
|
|
854
|
+
### Configuring IP Address Type
|
|
855
|
+
|
|
856
|
+
You can specify which IP protocol CloudFront uses when connecting to your Lambda Function URL origin. By default, CloudFront uses IPv4 only.
|
|
857
|
+
|
|
858
|
+
```ts
|
|
859
|
+
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
860
|
+
import { OriginIpAddressType } from 'aws-cdk-lib/aws-cloudfront';
|
|
861
|
+
|
|
862
|
+
declare const fn: lambda.Function;
|
|
863
|
+
const fnUrl = fn.addFunctionUrl({ authType: lambda.FunctionUrlAuthType.NONE });
|
|
864
|
+
|
|
865
|
+
// Uses default IPv4 only
|
|
866
|
+
new cloudfront.Distribution(this, 'Distribution', {
|
|
867
|
+
defaultBehavior: {
|
|
868
|
+
origin: new origins.FunctionUrlOrigin(fnUrl)
|
|
869
|
+
},
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// Explicitly specify IP address type
|
|
873
|
+
new cloudfront.Distribution(this, 'Distribution', {
|
|
874
|
+
defaultBehavior: {
|
|
875
|
+
origin: new origins.FunctionUrlOrigin(fnUrl, {
|
|
876
|
+
ipAddressType: OriginIpAddressType.DUALSTACK, // Use both IPv4 and IPv6
|
|
877
|
+
})
|
|
878
|
+
},
|
|
879
|
+
});
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
Supported values for `ipAddressType`:
|
|
883
|
+
- `OriginIpAddressType.IPV4` - CloudFront uses IPv4 only to connect to the origin (default)
|
|
884
|
+
- `OriginIpAddressType.IPV6` - CloudFront uses IPv6 only to connect to the origin
|
|
885
|
+
- `OriginIpAddressType.DUALSTACK` - CloudFront uses both IPv4 and IPv6 to connect to the origin
|
|
886
|
+
|
|
854
887
|
### Lambda Function URL with Origin Access Control (OAC)
|
|
855
888
|
You can configure the Lambda Function URL with Origin Access Control (OAC) for enhanced security. When using OAC with Signing SIGV4_ALWAYS, it is recommended to set the Lambda Function URL authType to AWS_IAM to ensure proper authorization.
|
|
856
889
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
2
|
+
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
3
|
+
import { FunctionUrlOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
4
|
+
import { App, Stack } from 'aws-cdk-lib';
|
|
5
|
+
import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
6
|
+
import { OriginIpAddressType } from 'aws-cdk-lib/aws-cloudfront';
|
|
7
|
+
|
|
8
|
+
const app = new App();
|
|
9
|
+
const stack = new Stack(app, 'FunctionUrlOriginIpAddressTypeStack');
|
|
10
|
+
|
|
11
|
+
// Lambda function
|
|
12
|
+
const fn = new lambda.Function(stack, 'TestFunction', {
|
|
13
|
+
code: lambda.Code.fromInline('exports.handler = async () => ({ statusCode: 200, body: "Hello" });'),
|
|
14
|
+
handler: 'index.handler',
|
|
15
|
+
runtime: lambda.Runtime.NODEJS_20_X,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Function URL with IAM auth
|
|
19
|
+
const fnUrl = fn.addFunctionUrl({
|
|
20
|
+
authType: lambda.FunctionUrlAuthType.AWS_IAM,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// CloudFront distribution with IPv4 IP address type
|
|
24
|
+
new cloudfront.Distribution(stack, 'DistributionWithoutIpAddressTypeProp(IPv4)', {
|
|
25
|
+
defaultBehavior: {
|
|
26
|
+
origin: FunctionUrlOrigin.withOriginAccessControl(fnUrl, {}),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// CloudFront distribution with IPv4 IP address type
|
|
31
|
+
const distributionIPv4 = new cloudfront.Distribution(stack, 'DistributionWithIPv4', {
|
|
32
|
+
defaultBehavior: {
|
|
33
|
+
origin: FunctionUrlOrigin.withOriginAccessControl(fnUrl, {
|
|
34
|
+
ipAddressType: OriginIpAddressType.IPV4,
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// CloudFront distribution with IPv6 IP address type
|
|
40
|
+
const distributionIPv6 = new cloudfront.Distribution(stack, 'DistributionWithIPv6', {
|
|
41
|
+
defaultBehavior: {
|
|
42
|
+
origin: FunctionUrlOrigin.withOriginAccessControl(fnUrl, {
|
|
43
|
+
ipAddressType: OriginIpAddressType.IPV6,
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// CloudFront distribution with dualstack IP address type
|
|
49
|
+
const distributionDualstack = new cloudfront.Distribution(stack, 'DistributionWithDualstack', {
|
|
50
|
+
defaultBehavior: {
|
|
51
|
+
origin: FunctionUrlOrigin.withOriginAccessControl(fnUrl, {
|
|
52
|
+
ipAddressType: OriginIpAddressType.DUALSTACK,
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const integ = new IntegTest(app, 'FunctionUrlOriginIpAddressTypeTest', {
|
|
58
|
+
testCases: [stack],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Assert that distributions are created with expected IP address type settings
|
|
62
|
+
integ.assertions.awsApiCall('CloudFront', 'getDistribution', {
|
|
63
|
+
Id: distributionIPv4.distributionId,
|
|
64
|
+
}).assertAtPath('Distribution.DistributionConfig.IsIPV4Enabled', ExpectedResult.exact(true));
|
|
65
|
+
|
|
66
|
+
integ.assertions.awsApiCall('CloudFront', 'getDistribution', {
|
|
67
|
+
Id: distributionIPv4.distributionId,
|
|
68
|
+
}).assertAtPath('Distribution.DistributionConfig.IsIPV6Enabled', ExpectedResult.exact(false));
|
|
69
|
+
|
|
70
|
+
integ.assertions.awsApiCall('CloudFront', 'getDistribution', {
|
|
71
|
+
Id: distributionIPv6.distributionId,
|
|
72
|
+
}).assertAtPath('Distribution.DistributionConfig.IsIPV4Enabled', ExpectedResult.exact(false));
|
|
73
|
+
|
|
74
|
+
integ.assertions.awsApiCall('CloudFront', 'getDistribution', {
|
|
75
|
+
Id: distributionIPv6.distributionId,
|
|
76
|
+
}).assertAtPath('Distribution.DistributionConfig.IsIPV6Enabled', ExpectedResult.exact(true));
|
|
77
|
+
|
|
78
|
+
integ.assertions.awsApiCall('CloudFront', 'getDistribution', {
|
|
79
|
+
Id: distributionDualstack.distributionId,
|
|
80
|
+
}).assertAtPath('Distribution.DistributionConfig.IsIPV4Enabled', ExpectedResult.exact(true));
|
|
81
|
+
|
|
82
|
+
integ.assertions.awsApiCall('CloudFront', 'getDistribution', {
|
|
83
|
+
Id: distributionDualstack.distributionId,
|
|
84
|
+
}).assertAtPath('Distribution.DistributionConfig.IsIPV6Enabled', ExpectedResult.exact(true));
|
|
@@ -479,7 +479,7 @@ const metric = new cloudwatch.Metric({
|
|
|
479
479
|
namespace: 'AWS/EC2',
|
|
480
480
|
metricName: 'CPUUtilization',
|
|
481
481
|
statistic: 'Average',
|
|
482
|
-
period: Duration.
|
|
482
|
+
period: Duration.hours(1), // Alarm will use the metric's period
|
|
483
483
|
});
|
|
484
484
|
|
|
485
485
|
// Create an anomaly detection alarm
|
|
@@ -5,12 +5,19 @@ import { Metric, ComparisonOperator, AnomalyDetectionAlarm, Alarm } from 'aws-cd
|
|
|
5
5
|
const app = new App();
|
|
6
6
|
const stack = new Stack(app, 'AnomalyDetectionAlarmTestStack');
|
|
7
7
|
|
|
8
|
-
// Create the test metric
|
|
8
|
+
// Create the test metric. Period will default to 300 seconds.
|
|
9
9
|
const metric = new Metric({
|
|
10
10
|
namespace: 'AWS/EC2',
|
|
11
11
|
metricName: 'CPUUtilization',
|
|
12
12
|
statistic: 'Average',
|
|
13
|
-
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Create test metric with custom period
|
|
16
|
+
const customPeriodMetric = new Metric({
|
|
17
|
+
namespace: 'AWS/EC2',
|
|
18
|
+
metricName: 'CPUUtilization',
|
|
19
|
+
statistic: 'Average',
|
|
20
|
+
period: Duration.days(1),
|
|
14
21
|
});
|
|
15
22
|
|
|
16
23
|
// Create an anomaly detection alarm with default operator
|
|
@@ -40,6 +47,14 @@ const descriptiveAlarm = Metric.anomalyDetectionFor({
|
|
|
40
47
|
comparisonOperator: ComparisonOperator.GREATER_THAN_UPPER_THRESHOLD,
|
|
41
48
|
});
|
|
42
49
|
|
|
50
|
+
// Create an anomaly detection alarm with custom period
|
|
51
|
+
const customPeriodAlarm = new AnomalyDetectionAlarm(stack, 'CustomPeriodAnomalyAlarm', {
|
|
52
|
+
metric: customPeriodMetric,
|
|
53
|
+
stdDevs: 2,
|
|
54
|
+
evaluationPeriods: 1,
|
|
55
|
+
comparisonOperator: ComparisonOperator.LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD,
|
|
56
|
+
});
|
|
57
|
+
|
|
43
58
|
// Create the integration test
|
|
44
59
|
const integ = new IntegTest(app, 'AnomalyDetectionAlarmIntegTest', {
|
|
45
60
|
testCases: [stack],
|
|
@@ -122,3 +137,30 @@ integ.assertions
|
|
|
122
137
|
}),
|
|
123
138
|
]),
|
|
124
139
|
}));
|
|
140
|
+
|
|
141
|
+
integ.assertions
|
|
142
|
+
.awsApiCall('CloudWatch', 'describeAlarms', {
|
|
143
|
+
AlarmNames: [customPeriodAlarm.alarmName],
|
|
144
|
+
})
|
|
145
|
+
.expect(ExpectedResult.objectLike({
|
|
146
|
+
MetricAlarms: Match.arrayWith([
|
|
147
|
+
Match.objectLike({
|
|
148
|
+
ComparisonOperator: 'LessThanLowerOrGreaterThanUpperThreshold',
|
|
149
|
+
EvaluationPeriods: 1,
|
|
150
|
+
ThresholdMetricId: 'expr_1',
|
|
151
|
+
Metrics: Match.arrayWith([
|
|
152
|
+
Match.objectLike({
|
|
153
|
+
Expression: 'ANOMALY_DETECTION_BAND(m0, 2)',
|
|
154
|
+
Id: 'expr_1',
|
|
155
|
+
ReturnData: true,
|
|
156
|
+
}),
|
|
157
|
+
Match.objectLike({
|
|
158
|
+
Id: 'm0',
|
|
159
|
+
MetricStat: Match.objectLike({
|
|
160
|
+
Period: 86400, // 1 day in seconds, orignal metric period got overriden
|
|
161
|
+
}),
|
|
162
|
+
}),
|
|
163
|
+
]),
|
|
164
|
+
}),
|
|
165
|
+
]),
|
|
166
|
+
}));
|
|
@@ -577,6 +577,82 @@ const fleet = new codebuild.Fleet(this, 'MyFleet', {
|
|
|
577
577
|
});
|
|
578
578
|
```
|
|
579
579
|
|
|
580
|
+
### Custom instance types
|
|
581
|
+
You can use [specific EC2 instance
|
|
582
|
+
types](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment-reserved-capacity.instance-types)
|
|
583
|
+
for your fleet by setting the `computeType` to `CUSTOM_INSTANCE_TYPE`. This
|
|
584
|
+
allows you to specify the `instanceType` in `computeConfiguration`. Only certain
|
|
585
|
+
EC2 instance types are supported; see the linked documentation for details.
|
|
586
|
+
|
|
587
|
+
```ts
|
|
588
|
+
import { Size } from 'aws-cdk-lib';
|
|
589
|
+
|
|
590
|
+
const fleet = new codebuild.Fleet(this, 'MyFleet', {
|
|
591
|
+
baseCapacity: 1,
|
|
592
|
+
computeType: codebuild.FleetComputeType.CUSTOM_INSTANCE_TYPE,
|
|
593
|
+
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
|
|
594
|
+
computeConfiguration: {
|
|
595
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
|
|
596
|
+
// By default, 64 GiB of disk space is included. Any value optionally
|
|
597
|
+
// specified here is _incremental_ on top of the included disk space.
|
|
598
|
+
disk: Size.gibibytes(10),
|
|
599
|
+
},
|
|
600
|
+
});
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### Fleet overflow behavior
|
|
604
|
+
|
|
605
|
+
When your builds exceed the capacity of your fleet, you can specify how CodeBuild should handle the overflow builds by setting the `overflowBehavior` property:
|
|
606
|
+
|
|
607
|
+
```ts
|
|
608
|
+
const fleet = new codebuild.Fleet(this, 'Fleet', {
|
|
609
|
+
computeType: codebuild.FleetComputeType.MEDIUM,
|
|
610
|
+
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
|
|
611
|
+
baseCapacity: 1,
|
|
612
|
+
overflowBehavior: codebuild.FleetOverflowBehavior.ON_DEMAND,
|
|
613
|
+
});
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
The available overflow behaviors are:
|
|
617
|
+
|
|
618
|
+
- `QUEUE` (default): Overflow builds wait for existing fleet instances to become available
|
|
619
|
+
- `ON_DEMAND`: Overflow builds run on CodeBuild on-demand instances
|
|
620
|
+
|
|
621
|
+
Note: If you set overflow behavior to `ON_DEMAND` for a VPC-connected fleet, ensure your VPC settings allow access to public AWS services.
|
|
622
|
+
|
|
623
|
+
### VPCs
|
|
624
|
+
The same considerations that apply to [Project
|
|
625
|
+
VPCs](#definition-of-vpc-configuration-in-codebuild-project) also apply to Fleet
|
|
626
|
+
VPCs. When using a Fleet in a CodeBuild Project, it is an error to configure a
|
|
627
|
+
VPC on the Project. Configure a VPC on the fleet instead.
|
|
628
|
+
|
|
629
|
+
```ts
|
|
630
|
+
declare const loadBalancer: elbv2.ApplicationLoadBalancer;
|
|
631
|
+
|
|
632
|
+
const vpc = new ec2.Vpc(this, 'MyVPC');
|
|
633
|
+
const fleet = new codebuild.Fleet(this, 'MyProject', {
|
|
634
|
+
computeType: codebuild.FleetComputeType.MEDIUM,
|
|
635
|
+
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
|
|
636
|
+
baseCapacity: 1,
|
|
637
|
+
vpc,
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
fleet.connections.allowTo(loadBalancer, ec2.Port.tcp(443));
|
|
641
|
+
|
|
642
|
+
const project = new codebuild.Project(this, 'MyProject', {
|
|
643
|
+
environment: {
|
|
644
|
+
fleet,
|
|
645
|
+
},
|
|
646
|
+
buildSpec: codebuild.BuildSpec.fromObject({
|
|
647
|
+
// ...
|
|
648
|
+
}),
|
|
649
|
+
// Trying to configure a project-level VPC is an error, because this project
|
|
650
|
+
// runs on the Fleet created above.
|
|
651
|
+
// vpc,
|
|
652
|
+
});
|
|
653
|
+
```
|
|
654
|
+
>>>>>>> 39ec36ec6a (feat(codebuild): add custom instance type and VPC to Fleets)
|
|
655
|
+
|
|
580
656
|
## Logs
|
|
581
657
|
|
|
582
658
|
CodeBuild lets you specify an S3 Bucket, CloudWatch Log Group or both to receive logs from your projects.
|
|
@@ -1,17 +1,55 @@
|
|
|
1
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
1
2
|
import * as cdk from 'aws-cdk-lib';
|
|
2
3
|
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
3
4
|
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
|
|
4
5
|
import { Construct } from 'constructs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
type StackConfiguration = {
|
|
8
|
+
computeConfiguration: codebuild.ComputeConfiguration;
|
|
9
|
+
vpcProps?: ec2.VpcProps;
|
|
10
|
+
subnetSelection?: ec2.SubnetSelection;
|
|
11
|
+
securityGroupProps?: Array<Omit<ec2.SecurityGroupProps, 'vpc'>>;
|
|
12
|
+
}
|
|
13
|
+
const configurations: Array<StackConfiguration> = [
|
|
14
|
+
{
|
|
15
|
+
computeConfiguration: {
|
|
16
|
+
machineType: codebuild.MachineType.GENERAL,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
7
19
|
{
|
|
8
|
-
|
|
20
|
+
computeConfiguration: {
|
|
21
|
+
machineType: codebuild.MachineType.GENERAL,
|
|
22
|
+
vCpu: 2,
|
|
23
|
+
memory: cdk.Size.gibibytes(4),
|
|
24
|
+
disk: cdk.Size.gibibytes(10),
|
|
25
|
+
},
|
|
9
26
|
},
|
|
10
27
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
computeConfiguration: {
|
|
29
|
+
machineType: codebuild.MachineType.GENERAL,
|
|
30
|
+
},
|
|
31
|
+
vpcProps: {
|
|
32
|
+
maxAzs: 1,
|
|
33
|
+
restrictDefaultSecurityGroup: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
computeConfiguration: {
|
|
38
|
+
machineType: codebuild.MachineType.GENERAL,
|
|
39
|
+
},
|
|
40
|
+
vpcProps: {
|
|
41
|
+
maxAzs: 1,
|
|
42
|
+
// Incredibly, if you pass a SubnetSelection that produces more than 1
|
|
43
|
+
// subnet, you currently get this error:
|
|
44
|
+
// > Resource handler returned message: "Invalid vpc config: the maximum number of subnets is 1
|
|
45
|
+
// This seems like a terrible limitation from the CodeBuild team.
|
|
46
|
+
// maxAzs: 2,
|
|
47
|
+
},
|
|
48
|
+
subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
|
|
49
|
+
securityGroupProps: [
|
|
50
|
+
{ allowAllOutbound: true },
|
|
51
|
+
{ allowAllIpv6Outbound: true },
|
|
52
|
+
],
|
|
15
53
|
},
|
|
16
54
|
];
|
|
17
55
|
|
|
@@ -19,14 +57,27 @@ class FleetStack extends cdk.Stack {
|
|
|
19
57
|
public readonly fleet: codebuild.Fleet;
|
|
20
58
|
public readonly project: codebuild.Project;
|
|
21
59
|
|
|
22
|
-
constructor(scope: Construct, id: string, computeConfiguration:
|
|
60
|
+
constructor(scope: Construct, id: string, { computeConfiguration, vpcProps, subnetSelection, securityGroupProps }: StackConfiguration) {
|
|
23
61
|
super(scope, id);
|
|
24
62
|
|
|
63
|
+
let vpc: ec2.Vpc | undefined;
|
|
64
|
+
let securityGroups: Array<ec2.SecurityGroup> | undefined;
|
|
65
|
+
if (vpcProps) {
|
|
66
|
+
vpc = new ec2.Vpc(this, 'Vpc', vpcProps);
|
|
67
|
+
const refinedVpc = vpc;
|
|
68
|
+
securityGroups = securityGroupProps?.map((props, i) =>
|
|
69
|
+
new ec2.SecurityGroup(this, `SecurityGroup${i}`, { ...props, vpc: refinedVpc }),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
25
73
|
this.fleet = new codebuild.Fleet(this, 'MyFleet', {
|
|
26
74
|
baseCapacity: 1,
|
|
27
75
|
computeType: codebuild.FleetComputeType.ATTRIBUTE_BASED,
|
|
28
76
|
computeConfiguration,
|
|
29
77
|
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
|
|
78
|
+
vpc,
|
|
79
|
+
securityGroups,
|
|
80
|
+
subnetSelection,
|
|
30
81
|
});
|
|
31
82
|
|
|
32
83
|
this.project = new codebuild.Project(this, 'MyProject', {
|
|
@@ -38,6 +89,7 @@ class FleetStack extends cdk.Stack {
|
|
|
38
89
|
}),
|
|
39
90
|
environment: {
|
|
40
91
|
buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
|
|
92
|
+
fleet: this.fleet,
|
|
41
93
|
},
|
|
42
94
|
});
|
|
43
95
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
3
|
+
import * as cdk from 'aws-cdk-lib';
|
|
4
|
+
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
|
|
5
|
+
import { Construct } from 'constructs';
|
|
6
|
+
|
|
7
|
+
type StackConfiguration = {
|
|
8
|
+
computeConfiguration: codebuild.ComputeConfiguration;
|
|
9
|
+
vpcProps?: ec2.VpcProps;
|
|
10
|
+
subnetSelection?: ec2.SubnetSelection;
|
|
11
|
+
securityGroupProps?: Array<Omit<ec2.SecurityGroupProps, 'vpc'>>;
|
|
12
|
+
}
|
|
13
|
+
const configurations: Array<StackConfiguration> = [
|
|
14
|
+
{
|
|
15
|
+
computeConfiguration: {
|
|
16
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
computeConfiguration: {
|
|
21
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
|
|
22
|
+
disk: cdk.Size.gibibytes(10),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
computeConfiguration: {
|
|
27
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
|
|
28
|
+
},
|
|
29
|
+
vpcProps: {
|
|
30
|
+
maxAzs: 1,
|
|
31
|
+
restrictDefaultSecurityGroup: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
computeConfiguration: {
|
|
36
|
+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
|
|
37
|
+
},
|
|
38
|
+
vpcProps: {
|
|
39
|
+
maxAzs: 1,
|
|
40
|
+
// Incredibly, if you pass a SubnetSelection that produces more than 1
|
|
41
|
+
// subnet, you currently get this error:
|
|
42
|
+
// > Resource handler returned message: "Invalid vpc config: the maximum number of subnets is 1
|
|
43
|
+
// This seems like a terrible limitation from the CodeBuild team.
|
|
44
|
+
// maxAzs: 2,
|
|
45
|
+
},
|
|
46
|
+
subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
|
|
47
|
+
securityGroupProps: [
|
|
48
|
+
{ allowAllOutbound: true },
|
|
49
|
+
{ allowAllIpv6Outbound: true },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
class FleetStack extends cdk.Stack {
|
|
55
|
+
public readonly fleet: codebuild.Fleet;
|
|
56
|
+
public readonly project: codebuild.Project;
|
|
57
|
+
|
|
58
|
+
constructor(scope: Construct, id: string, { computeConfiguration, vpcProps, subnetSelection, securityGroupProps }: StackConfiguration) {
|
|
59
|
+
super(scope, id);
|
|
60
|
+
|
|
61
|
+
let vpc: ec2.Vpc | undefined;
|
|
62
|
+
let securityGroups: Array<ec2.SecurityGroup> | undefined;
|
|
63
|
+
if (vpcProps) {
|
|
64
|
+
vpc = new ec2.Vpc(this, 'Vpc', vpcProps);
|
|
65
|
+
const refinedVpc = vpc;
|
|
66
|
+
securityGroups = securityGroupProps?.map((props, i) =>
|
|
67
|
+
new ec2.SecurityGroup(this, `SecurityGroup${i}`, { ...props, vpc: refinedVpc }),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.fleet = new codebuild.Fleet(this, 'MyFleet', {
|
|
72
|
+
baseCapacity: 1,
|
|
73
|
+
computeType: codebuild.FleetComputeType.CUSTOM_INSTANCE_TYPE,
|
|
74
|
+
computeConfiguration,
|
|
75
|
+
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
|
|
76
|
+
vpc,
|
|
77
|
+
securityGroups,
|
|
78
|
+
subnetSelection,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
this.project = new codebuild.Project(this, 'MyProject', {
|
|
82
|
+
buildSpec: codebuild.BuildSpec.fromObject({
|
|
83
|
+
version: '0.2',
|
|
84
|
+
phases: {
|
|
85
|
+
build: { commands: ['echo "Nothing to do!"'] },
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
environment: {
|
|
89
|
+
buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
|
|
90
|
+
fleet: this.fleet,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const app = new cdk.App();
|
|
97
|
+
const stacks = configurations.map(
|
|
98
|
+
(config, index) => new FleetStack(
|
|
99
|
+
app,
|
|
100
|
+
`CustomInstanceTypeComputeFleetIntegStack${index}`,
|
|
101
|
+
config,
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const test = new integ.IntegTest(app, 'CustomInstanceTypeComputeFleetIntegTest', {
|
|
106
|
+
testCases: stacks,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const listFleets = test.assertions.awsApiCall('Codebuild', 'listFleets');
|
|
110
|
+
for (const { fleet, project } of stacks) {
|
|
111
|
+
listFleets.expect(integ.ExpectedResult.objectLike({
|
|
112
|
+
fleets: integ.Match.arrayWith([fleet.fleetArn]),
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
const startBuild = test.assertions.awsApiCall('Codebuild', 'startBuild', { projectName: project.projectName });
|
|
116
|
+
|
|
117
|
+
// Describe the build and wait for the status to be successful
|
|
118
|
+
test.assertions.awsApiCall('CodeBuild', 'batchGetBuilds', {
|
|
119
|
+
ids: [startBuild.getAttString('build.id')],
|
|
120
|
+
}).assertAtPath(
|
|
121
|
+
'builds.0.buildStatus',
|
|
122
|
+
integ.ExpectedResult.stringLikeRegexp('SUCCEEDED'),
|
|
123
|
+
).waitForAssertions({
|
|
124
|
+
// After a custom instance type fleet is created, there can still be high
|
|
125
|
+
// latency on creating actual instances. Needs a long timeout, builds are
|
|
126
|
+
// pending until instances are initialized.
|
|
127
|
+
totalTimeout: cdk.Duration.minutes(10),
|
|
128
|
+
interval: cdk.Duration.seconds(30),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
3
|
+
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
|
|
4
|
+
import { Construct } from 'constructs';
|
|
5
|
+
|
|
6
|
+
class FleetStack extends cdk.Stack {
|
|
7
|
+
public readonly fleet: codebuild.Fleet;
|
|
8
|
+
public readonly project: codebuild.Project;
|
|
9
|
+
|
|
10
|
+
constructor(scope: Construct, id: string) {
|
|
11
|
+
super(scope, id);
|
|
12
|
+
|
|
13
|
+
this.fleet = new codebuild.Fleet(this, 'MyFleet', {
|
|
14
|
+
baseCapacity: 1,
|
|
15
|
+
computeType: codebuild.FleetComputeType.SMALL,
|
|
16
|
+
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
|
|
17
|
+
overflowBehavior: codebuild.FleetOverflowBehavior.ON_DEMAND,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
this.project = new codebuild.Project(this, 'MyProject', {
|
|
21
|
+
buildSpec: codebuild.BuildSpec.fromObject({
|
|
22
|
+
version: '0.2',
|
|
23
|
+
phases: {
|
|
24
|
+
build: { commands: ['echo "Nothing to do!"'] },
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
environment: {
|
|
28
|
+
fleet: this.fleet,
|
|
29
|
+
buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const app = new cdk.App();
|
|
36
|
+
const stack= new FleetStack(
|
|
37
|
+
app,
|
|
38
|
+
'OverflowBehaviorFleetStack',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const test = new integ.IntegTest(app, 'OverflowBehaviorFleetInteg', {
|
|
42
|
+
testCases: [stack],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const listFleets = test.assertions.awsApiCall('Codebuild', 'listFleets');
|
|
46
|
+
listFleets.expect(integ.ExpectedResult.objectLike({
|
|
47
|
+
fleets: integ.Match.arrayWith([stack.fleet.fleetArn]),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const startBuild = test.assertions.awsApiCall('Codebuild', 'startBuild', { projectName: stack.project.projectName });
|
|
51
|
+
|
|
52
|
+
// Describe the build and wait for the status to be successful
|
|
53
|
+
test.assertions.awsApiCall('CodeBuild', 'batchGetBuilds', {
|
|
54
|
+
ids: [startBuild.getAttString('build.id')],
|
|
55
|
+
}).assertAtPath(
|
|
56
|
+
'builds.0.buildStatus',
|
|
57
|
+
integ.ExpectedResult.stringLikeRegexp('SUCCEEDED'),
|
|
58
|
+
).waitForAssertions({
|
|
59
|
+
totalTimeout: cdk.Duration.minutes(5),
|
|
60
|
+
interval: cdk.Duration.seconds(30),
|
|
61
|
+
});
|