Skip to content

Commit cf5a9c4

Browse files
authored
feat(apprunner-alpha): support autoDeploymentsEnabled flag for Service (#24612)
The alpha construct for AWS App Runner is missing an option to set auto deployment settings. Users now can specify the `autoDeploymentsEnbaled` flag in the construct props. Closes #24529 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7d17fe3 commit cf5a9c4

17 files changed

+191
-58
lines changed

Diff for: packages/@aws-cdk/aws-apprunner/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ new apprunner.Service(this, 'Service', {
7070
});
7171
```
7272

73-
To create a `Service` from local docker image asset directory built and pushed to Amazon ECR:
73+
To create a `Service` from local docker image asset directory built and pushed to Amazon ECR:
74+
75+
You can specify whether to enable continuous integration from the source repository with the `autoDeploymentsEnabled` flag.
7476

7577
```ts
7678
import * as assets from '@aws-cdk/aws-ecr-assets';
@@ -83,6 +85,7 @@ new apprunner.Service(this, 'Service', {
8385
imageConfiguration: { port: 8000 },
8486
asset: imageAsset,
8587
}),
88+
autoDeploymentsEnabled: true,
8689
});
8790
```
8891

Diff for: packages/@aws-cdk/aws-apprunner/lib/service.ts

+13
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,18 @@ export interface ServiceProps {
575575
*/
576576
readonly source: Source;
577577

578+
/**
579+
* Specifies whether to enable continuous integration from the source repository.
580+
*
581+
* If true, continuous integration from the source repository is enabled for the App Runner service.
582+
* Each repository change (including any source code commit or new image version) starts a deployment.
583+
* By default, App Runner sets to false for a source image that uses an ECR Public repository or an ECR repository that's in an AWS account other than the one that the service is in.
584+
* App Runner sets to true in all other cases (which currently include a source code repository or a source image using a same-account ECR repository).
585+
*
586+
* @default - no value will be passed.
587+
*/
588+
readonly autoDeploymentsEnabled?: boolean;
589+
578590
/**
579591
* The number of CPU units reserved for each instance of your App Runner service.
580592
*
@@ -1001,6 +1013,7 @@ export class Service extends cdk.Resource {
10011013
},
10021014
sourceConfiguration: {
10031015
authenticationConfiguration: this.renderAuthenticationConfiguration(),
1016+
autoDeploymentsEnabled: this.props.autoDeploymentsEnabled,
10041017
imageRepository: this.source.imageRepository ?
10051018
this.renderImageRepository(this.source.imageRepository!) :
10061019
undefined,
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"21.0.0"}
1+
{"version":"31.0.0"}

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"files": {
4-
"6d79089acf2375f6d13fb41fba9ce0ebfac06ddf21b1dccfbb19155dfee25760": {
4+
"f00e06a7824495556404fb0a324a2b16e71836ea8aee2588858ad09bad6da100": {
55
"source": {
66
"path": "integ-apprunner-ecr-public.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "6d79089acf2375f6d13fb41fba9ce0ebfac06ddf21b1dccfbb19155dfee25760.json",
12+
"objectKey": "f00e06a7824495556404fb0a324a2b16e71836ea8aee2588858ad09bad6da100.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.template.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Properties": {
66
"SourceConfiguration": {
77
"AuthenticationConfiguration": {},
8+
"AutoDeploymentsEnabled": false,
89
"ImageRepository": {
910
"ImageConfiguration": {
1011
"Port": "8000"

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"testCases": {
44
"integ.service-ecr-public": {
55
"stacks": [

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.js.snapshot/manifest.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"artifacts": {
4-
"Tree": {
5-
"type": "cdk:tree",
6-
"properties": {
7-
"file": "tree.json"
8-
}
9-
},
104
"integ-apprunner-ecr-public.assets": {
115
"type": "cdk:asset-manifest",
126
"properties": {
@@ -23,7 +17,7 @@
2317
"validateOnSynth": false,
2418
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2519
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6d79089acf2375f6d13fb41fba9ce0ebfac06ddf21b1dccfbb19155dfee25760.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f00e06a7824495556404fb0a324a2b16e71836ea8aee2588858ad09bad6da100.json",
2721
"requiresBootstrapStackVersion": 6,
2822
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2923
"additionalDependencies": [
@@ -65,6 +59,12 @@
6559
]
6660
},
6761
"displayName": "integ-apprunner-ecr-public"
62+
},
63+
"Tree": {
64+
"type": "cdk:tree",
65+
"properties": {
66+
"file": "tree.json"
67+
}
6868
}
6969
}
7070
}

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.js.snapshot/tree.json

+30-13
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
"id": "App",
55
"path": "",
66
"children": {
7-
"Tree": {
8-
"id": "Tree",
9-
"path": "Tree",
10-
"constructInfo": {
11-
"fqn": "constructs.Construct",
12-
"version": "10.1.85"
13-
}
14-
},
157
"integ-apprunner-ecr-public": {
168
"id": "integ-apprunner-ecr-public",
179
"path": "integ-apprunner-ecr-public",
@@ -28,6 +20,7 @@
2820
"aws:cdk:cloudformation:props": {
2921
"sourceConfiguration": {
3022
"authenticationConfiguration": {},
23+
"autoDeploymentsEnabled": false,
3124
"imageRepository": {
3225
"imageConfiguration": {
3326
"port": "8000"
@@ -59,20 +52,44 @@
5952
"id": "URL1",
6053
"path": "integ-apprunner-ecr-public/URL1",
6154
"constructInfo": {
62-
"fqn": "constructs.Construct",
63-
"version": "10.1.85"
55+
"fqn": "@aws-cdk/core.CfnOutput",
56+
"version": "0.0.0"
57+
}
58+
},
59+
"BootstrapVersion": {
60+
"id": "BootstrapVersion",
61+
"path": "integ-apprunner-ecr-public/BootstrapVersion",
62+
"constructInfo": {
63+
"fqn": "@aws-cdk/core.CfnParameter",
64+
"version": "0.0.0"
65+
}
66+
},
67+
"CheckBootstrapVersion": {
68+
"id": "CheckBootstrapVersion",
69+
"path": "integ-apprunner-ecr-public/CheckBootstrapVersion",
70+
"constructInfo": {
71+
"fqn": "@aws-cdk/core.CfnRule",
72+
"version": "0.0.0"
6473
}
6574
}
6675
},
76+
"constructInfo": {
77+
"fqn": "@aws-cdk/core.Stack",
78+
"version": "0.0.0"
79+
}
80+
},
81+
"Tree": {
82+
"id": "Tree",
83+
"path": "Tree",
6784
"constructInfo": {
6885
"fqn": "constructs.Construct",
69-
"version": "10.1.85"
86+
"version": "10.1.252"
7087
}
7188
}
7289
},
7390
"constructInfo": {
74-
"fqn": "constructs.Construct",
75-
"version": "10.1.85"
91+
"fqn": "@aws-cdk/core.App",
92+
"version": "0.0.0"
7693
}
7794
}
7895
}

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ const service1 = new Service(stack, 'Service1', {
1414
},
1515
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
1616
}),
17+
autoDeploymentsEnabled: false,
1718
});
1819
new cdk.CfnOutput(stack, 'URL1', { value: `https://${service1.serviceUrl}` });
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"21.0.0"}
1+
{"version":"31.0.0"}

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.js.snapshot/integ-apprunner.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"files": {
4-
"d21fee6f9384d15c5a0a826f4dbc23d103a989e9cc2e9c8abc2a629de9ea5cd2": {
4+
"3f9deb43f8f02da8be7c2aa727a501250dbddc1fd19e848d488e7071380ce060": {
55
"source": {
66
"path": "integ-apprunner.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "d21fee6f9384d15c5a0a826f4dbc23d103a989e9cc2e9c8abc2a629de9ea5cd2.json",
12+
"objectKey": "3f9deb43f8f02da8be7c2aa727a501250dbddc1fd19e848d488e7071380ce060.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.js.snapshot/integ-apprunner.template.json

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
]
8282
}
8383
},
84+
"AutoDeploymentsEnabled": true,
8485
"ImageRepository": {
8586
"ImageConfiguration": {
8687
"Port": "8000"

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"testCases": {
44
"integ.service-ecr": {
55
"stacks": [

Diff for: packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.js.snapshot/manifest.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"artifacts": {
4-
"Tree": {
5-
"type": "cdk:tree",
6-
"properties": {
7-
"file": "tree.json"
8-
}
9-
},
104
"integ-apprunner.assets": {
115
"type": "cdk:asset-manifest",
126
"properties": {
@@ -23,7 +17,7 @@
2317
"validateOnSynth": false,
2418
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2519
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/d21fee6f9384d15c5a0a826f4dbc23d103a989e9cc2e9c8abc2a629de9ea5cd2.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3f9deb43f8f02da8be7c2aa727a501250dbddc1fd19e848d488e7071380ce060.json",
2721
"requiresBootstrapStackVersion": 6,
2822
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2923
"additionalDependencies": [
@@ -101,6 +95,12 @@
10195
]
10296
},
10397
"displayName": "integ-apprunner"
98+
},
99+
"Tree": {
100+
"type": "cdk:tree",
101+
"properties": {
102+
"file": "tree.json"
103+
}
104104
}
105105
}
106106
}

0 commit comments

Comments
 (0)