Skip to content

Commit 665396f

Browse files
authored
feat(apprunner): add ipAddressType property to the Service class (#30351)
### Issue # (if applicable) N/A ### Reason for this change AppRunner supported Dual Stack. https://aws.amazon.com/about-aws/whats-new/2023/11/aws-app-runner-supports-ipv6-public-inbound-traffic/?nc1=h_ls But current L2 Construct (alpha module) does not support it. ### Description of changes Add ipAddressType property to the Service class ### Description of how you validated changes Add unit tests and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5114955 commit 665396f

12 files changed

+610
-1
lines changed

packages/@aws-cdk/aws-apprunner-alpha/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ new apprunner.Service(this, 'Service', {
180180
});
181181
```
182182

183+
## Dual Stack
184+
185+
To use dual stack (IPv4 and IPv6) for your incoming public network configuration, set `ipAddressType` to `IpAddressType.DUAL_STACK`.
186+
187+
```ts
188+
new apprunner.Service(this, 'Service', {
189+
source: apprunner.Source.fromEcrPublic({
190+
imageConfiguration: { port: 8000 },
191+
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
192+
}),
193+
ipAddressType: apprunner.IpAddressType.DUAL_STACK,
194+
});
195+
```
196+
197+
**Note**: Currently, App Runner supports dual stack for only Public endpoint.
198+
Only IPv4 is supported for Private endpoint.
199+
If you update a service that's using dual-stack Public endpoint to a Private endpoint,
200+
your App Runner service will default to support only IPv4 for Private endpoint and fail
201+
to receive traffic originating from IPv6 endpoint.
202+
183203
## Secrets Manager
184204

185205
To include environment variables integrated with AWS Secrets Manager, use the `environmentSecrets` attribute.

packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts

+23
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,13 @@ export interface ServiceProps {
723723
* @default - Use an AWS managed key
724724
*/
725725
readonly kmsKey?: kms.IKey;
726+
727+
/**
728+
* The IP address type for your incoming public network configuration.
729+
*
730+
* @default - IpAddressType.IPV4
731+
*/
732+
readonly ipAddressType?: IpAddressType;
726733
}
727734

728735
/**
@@ -1004,6 +1011,21 @@ export class HealthCheck {
10041011
}
10051012
}
10061013

1014+
/**
1015+
* The IP address type for your incoming public network configuration.
1016+
*/
1017+
export enum IpAddressType {
1018+
/**
1019+
* IPV4
1020+
*/
1021+
IPV4 = 'IPV4',
1022+
1023+
/**
1024+
* DUAL_STACK
1025+
*/
1026+
DUAL_STACK = 'DUAL_STACK',
1027+
}
1028+
10071029
/**
10081030
* Attributes for the App Runner Service
10091031
*/
@@ -1255,6 +1277,7 @@ export class Service extends cdk.Resource implements iam.IGrantable {
12551277
egressType: this.props.vpcConnector ? 'VPC' : 'DEFAULT',
12561278
vpcConnectorArn: this.props.vpcConnector?.vpcConnectorArn,
12571279
},
1280+
ipAddressType: this.props.ipAddressType,
12581281
},
12591282
healthCheckConfiguration: this.props.healthCheck ?
12601283
this.props.healthCheck.bind() :

packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"Resources": {
3+
"ServiceInstanceRoleDFA90CEC": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "tasks.apprunner.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
}
18+
}
19+
},
20+
"ServiceDBC79909": {
21+
"Type": "AWS::AppRunner::Service",
22+
"Properties": {
23+
"InstanceConfiguration": {
24+
"InstanceRoleArn": {
25+
"Fn::GetAtt": [
26+
"ServiceInstanceRoleDFA90CEC",
27+
"Arn"
28+
]
29+
}
30+
},
31+
"NetworkConfiguration": {
32+
"EgressConfiguration": {
33+
"EgressType": "DEFAULT"
34+
},
35+
"IpAddressType": "DUAL_STACK"
36+
},
37+
"ServiceName": "service",
38+
"SourceConfiguration": {
39+
"AuthenticationConfiguration": {},
40+
"AutoDeploymentsEnabled": false,
41+
"ImageRepository": {
42+
"ImageConfiguration": {
43+
"Port": "8000"
44+
},
45+
"ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest",
46+
"ImageRepositoryType": "ECR_PUBLIC"
47+
}
48+
}
49+
}
50+
}
51+
},
52+
"Outputs": {
53+
"URL": {
54+
"Value": {
55+
"Fn::Join": [
56+
"",
57+
[
58+
"https://",
59+
{
60+
"Fn::GetAtt": [
61+
"ServiceDBC79909",
62+
"ServiceUrl"
63+
]
64+
}
65+
]
66+
]
67+
}
68+
}
69+
},
70+
"Parameters": {
71+
"BootstrapVersion": {
72+
"Type": "AWS::SSM::Parameter::Value<String>",
73+
"Default": "/cdk-bootstrap/hnb659fds/version",
74+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
75+
}
76+
},
77+
"Rules": {
78+
"CheckBootstrapVersion": {
79+
"Assertions": [
80+
{
81+
"Assert": {
82+
"Fn::Not": [
83+
{
84+
"Fn::Contains": [
85+
[
86+
"1",
87+
"2",
88+
"3",
89+
"4",
90+
"5"
91+
],
92+
{
93+
"Ref": "BootstrapVersion"
94+
}
95+
]
96+
}
97+
]
98+
},
99+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
100+
}
101+
]
102+
}
103+
}
104+
}

packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)