From 665396fa8485ab642c27acf30df85f2b023acde4 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Tue, 11 Jun 2024 09:04:14 +0900 Subject: [PATCH] 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* --- .../@aws-cdk/aws-apprunner-alpha/README.md | 20 ++ .../aws-apprunner-alpha/lib/service.ts | 23 ++ ...efaultTestDeployAssertAC7DD6FC.assets.json | 19 ++ ...aultTestDeployAssertAC7DD6FC.template.json | 36 ++++ .../cdk.out | 1 + ...nteg-apprunner-ip-address-type.assets.json | 19 ++ ...eg-apprunner-ip-address-type.template.json | 104 +++++++++ .../integ.json | 12 ++ .../manifest.json | 125 +++++++++++ .../tree.json | 201 ++++++++++++++++++ .../test/integ.service-ip-address-type.ts | 27 +++ .../aws-apprunner-alpha/test/service.test.ts | 24 ++- 12 files changed, 610 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts diff --git a/packages/@aws-cdk/aws-apprunner-alpha/README.md b/packages/@aws-cdk/aws-apprunner-alpha/README.md index 22c95ccdf2b23..845a1eb34c447 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/README.md +++ b/packages/@aws-cdk/aws-apprunner-alpha/README.md @@ -180,6 +180,26 @@ new apprunner.Service(this, 'Service', { }); ``` +## Dual Stack + +To use dual stack (IPv4 and IPv6) for your incoming public network configuration, set `ipAddressType` to `IpAddressType.DUAL_STACK`. + +```ts +new apprunner.Service(this, 'Service', { + source: apprunner.Source.fromEcrPublic({ + imageConfiguration: { port: 8000 }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), + ipAddressType: apprunner.IpAddressType.DUAL_STACK, +}); +``` + +**Note**: Currently, App Runner supports dual stack for only Public endpoint. +Only IPv4 is supported for Private endpoint. +If you update a service that's using dual-stack Public endpoint to a Private endpoint, +your App Runner service will default to support only IPv4 for Private endpoint and fail +to receive traffic originating from IPv6 endpoint. + ## Secrets Manager To include environment variables integrated with AWS Secrets Manager, use the `environmentSecrets` attribute. diff --git a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts index c66fb75d850bf..412372e18bb90 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts @@ -723,6 +723,13 @@ export interface ServiceProps { * @default - Use an AWS managed key */ readonly kmsKey?: kms.IKey; + + /** + * The IP address type for your incoming public network configuration. + * + * @default - IpAddressType.IPV4 + */ + readonly ipAddressType?: IpAddressType; } /** @@ -1004,6 +1011,21 @@ export class HealthCheck { } } +/** + * The IP address type for your incoming public network configuration. + */ +export enum IpAddressType { + /** + * IPV4 + */ + IPV4 = 'IPV4', + + /** + * DUAL_STACK + */ + DUAL_STACK = 'DUAL_STACK', +} + /** * Attributes for the App Runner Service */ @@ -1255,6 +1277,7 @@ export class Service extends cdk.Resource implements iam.IGrantable { egressType: this.props.vpcConnector ? 'VPC' : 'DEFAULT', vpcConnectorArn: this.props.vpcConnector?.vpcConnectorArn, }, + ipAddressType: this.props.ipAddressType, }, healthCheckConfiguration: this.props.healthCheck ? this.props.healthCheck.bind() : diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json new file mode 100644 index 0000000000000..c1ed20a783b61 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json new file mode 100644 index 0000000000000..3edc2aa75e54b --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "f9e956fb5e2f791153ea7f9505e67fce8b218eac61d16971b414879ba0b5e11d": { + "source": { + "path": "integ-apprunner-ip-address-type.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "f9e956fb5e2f791153ea7f9505e67fce8b218eac61d16971b414879ba0b5e11d.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json new file mode 100644 index 0000000000000..03051f42579aa --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json @@ -0,0 +1,104 @@ +{ + "Resources": { + "ServiceInstanceRoleDFA90CEC": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "tasks.apprunner.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "ServiceDBC79909": { + "Type": "AWS::AppRunner::Service", + "Properties": { + "InstanceConfiguration": { + "InstanceRoleArn": { + "Fn::GetAtt": [ + "ServiceInstanceRoleDFA90CEC", + "Arn" + ] + } + }, + "NetworkConfiguration": { + "EgressConfiguration": { + "EgressType": "DEFAULT" + }, + "IpAddressType": "DUAL_STACK" + }, + "ServiceName": "service", + "SourceConfiguration": { + "AuthenticationConfiguration": {}, + "AutoDeploymentsEnabled": false, + "ImageRepository": { + "ImageConfiguration": { + "Port": "8000" + }, + "ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest", + "ImageRepositoryType": "ECR_PUBLIC" + } + } + } + } + }, + "Outputs": { + "URL": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::GetAtt": [ + "ServiceDBC79909", + "ServiceUrl" + ] + } + ] + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json new file mode 100644 index 0000000000000..40c51edee8188 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "AppRunnerIpAddressType/DefaultTest": { + "stacks": [ + "integ-apprunner-ip-address-type" + ], + "assertionStack": "AppRunnerIpAddressType/DefaultTest/DeployAssert", + "assertionStackName": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json new file mode 100644 index 0000000000000..1f50a8f75aebc --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json @@ -0,0 +1,125 @@ +{ + "version": "36.0.0", + "artifacts": { + "integ-apprunner-ip-address-type.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-apprunner-ip-address-type.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-apprunner-ip-address-type": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integ-apprunner-ip-address-type.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f9e956fb5e2f791153ea7f9505e67fce8b218eac61d16971b414879ba0b5e11d.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-apprunner-ip-address-type.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integ-apprunner-ip-address-type.assets" + ], + "metadata": { + "/integ-apprunner-ip-address-type/Service/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ServiceInstanceRoleDFA90CEC" + } + ], + "/integ-apprunner-ip-address-type/Service/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ServiceDBC79909" + } + ], + "/integ-apprunner-ip-address-type/URL": [ + { + "type": "aws:cdk:logicalId", + "data": "URL" + } + ], + "/integ-apprunner-ip-address-type/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-apprunner-ip-address-type/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-apprunner-ip-address-type" + }, + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets" + ], + "metadata": { + "/AppRunnerIpAddressType/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/AppRunnerIpAddressType/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "AppRunnerIpAddressType/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json new file mode 100644 index 0000000000000..06ea3cb77a255 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json @@ -0,0 +1,201 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-apprunner-ip-address-type": { + "id": "integ-apprunner-ip-address-type", + "path": "integ-apprunner-ip-address-type", + "children": { + "Service": { + "id": "Service", + "path": "integ-apprunner-ip-address-type/Service", + "children": { + "InstanceRole": { + "id": "InstanceRole", + "path": "integ-apprunner-ip-address-type/Service/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "integ-apprunner-ip-address-type/Service/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-apprunner-ip-address-type/Service/InstanceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "tasks.apprunner.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-apprunner-ip-address-type/Service/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppRunner::Service", + "aws:cdk:cloudformation:props": { + "instanceConfiguration": { + "instanceRoleArn": { + "Fn::GetAtt": [ + "ServiceInstanceRoleDFA90CEC", + "Arn" + ] + } + }, + "networkConfiguration": { + "egressConfiguration": { + "egressType": "DEFAULT" + }, + "ipAddressType": "DUAL_STACK" + }, + "serviceName": "service", + "sourceConfiguration": { + "authenticationConfiguration": {}, + "autoDeploymentsEnabled": false, + "imageRepository": { + "imageConfiguration": { + "port": "8000" + }, + "imageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest", + "imageRepositoryType": "ECR_PUBLIC" + } + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apprunner.CfnService", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "URL": { + "id": "URL", + "path": "integ-apprunner-ip-address-type/URL", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-apprunner-ip-address-type/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-apprunner-ip-address-type/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "AppRunnerIpAddressType": { + "id": "AppRunnerIpAddressType", + "path": "AppRunnerIpAddressType", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "AppRunnerIpAddressType/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "AppRunnerIpAddressType/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "AppRunnerIpAddressType/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "AppRunnerIpAddressType/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "AppRunnerIpAddressType/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts new file mode 100644 index 0000000000000..d1b9194f0f3cd --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts @@ -0,0 +1,27 @@ +import * as cdk from 'aws-cdk-lib'; +import { IpAddressType, Service, Source } from '../lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'integ-apprunner-ip-address-type'); + +const service = new Service(stack, 'Service', { + serviceName: 'service', + source: Source.fromEcrPublic({ + imageConfiguration: { + port: 8000, + }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), + autoDeploymentsEnabled: false, + ipAddressType: IpAddressType.DUAL_STACK, +}); + +new cdk.CfnOutput(stack, 'URL', { value: `https://${service.serviceUrl}` }); + +new integ.IntegTest(app, 'AppRunnerIpAddressType', { + testCases: [stack], +}); + +app.synth(); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts index 389c36de9c7b5..6843cd13a3bc5 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts @@ -1604,4 +1604,26 @@ test('create a service with a customer managed key)', () => { KmsKey: stack.resolve(key.keyArn), }, }); -}); \ No newline at end of file +}); + +test.each([apprunner.IpAddressType.IPV4, apprunner.IpAddressType.DUAL_STACK])('ipAddressType is set %s', (ipAddressType: apprunner.IpAddressType) => { + // GIVEN + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'demo-stack'); + + // WHEN + new apprunner.Service(stack, 'DemoService', { + source: apprunner.Source.fromEcrPublic({ + imageConfiguration: { port: 8000 }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), + ipAddressType, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::AppRunner::Service', { + NetworkConfiguration: { + IpAddressType: ipAddressType, + }, + }); +});