Skip to content

Commit

Permalink
feat(apprunner-alpha): support autoDeploymentsEnabled flag for Service (
Browse files Browse the repository at this point in the history
#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*
  • Loading branch information
ymhiroki authored Mar 22, 2023
1 parent 7d17fe3 commit cf5a9c4
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 58 deletions.
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-apprunner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ new apprunner.Service(this, 'Service', {
});
```

To create a `Service` from local docker image asset directory built and pushed to Amazon ECR:
To create a `Service` from local docker image asset directory built and pushed to Amazon ECR:

You can specify whether to enable continuous integration from the source repository with the `autoDeploymentsEnabled` flag.

```ts
import * as assets from '@aws-cdk/aws-ecr-assets';
Expand All @@ -83,6 +85,7 @@ new apprunner.Service(this, 'Service', {
imageConfiguration: { port: 8000 },
asset: imageAsset,
}),
autoDeploymentsEnabled: true,
});
```

Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-apprunner/lib/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,18 @@ export interface ServiceProps {
*/
readonly source: Source;

/**
* Specifies whether to enable continuous integration from the source repository.
*
* If true, continuous integration from the source repository is enabled for the App Runner service.
* Each repository change (including any source code commit or new image version) starts a deployment.
* 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.
* 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).
*
* @default - no value will be passed.
*/
readonly autoDeploymentsEnabled?: boolean;

/**
* The number of CPU units reserved for each instance of your App Runner service.
*
Expand Down Expand Up @@ -1001,6 +1013,7 @@ export class Service extends cdk.Resource {
},
sourceConfiguration: {
authenticationConfiguration: this.renderAuthenticationConfiguration(),
autoDeploymentsEnabled: this.props.autoDeploymentsEnabled,
imageRepository: this.source.imageRepository ?
this.renderImageRepository(this.source.imageRepository!) :
undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"31.0.0"}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "20.0.0",
"version": "31.0.0",
"files": {
"6d79089acf2375f6d13fb41fba9ce0ebfac06ddf21b1dccfbb19155dfee25760": {
"f00e06a7824495556404fb0a324a2b16e71836ea8aee2588858ad09bad6da100": {
"source": {
"path": "integ-apprunner-ecr-public.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "6d79089acf2375f6d13fb41fba9ce0ebfac06ddf21b1dccfbb19155dfee25760.json",
"objectKey": "f00e06a7824495556404fb0a324a2b16e71836ea8aee2588858ad09bad6da100.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {},
"AutoDeploymentsEnabled": false,
"ImageRepository": {
"ImageConfiguration": {
"Port": "8000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "31.0.0",
"testCases": {
"integ.service-ecr-public": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"version": "20.0.0",
"version": "31.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"integ-apprunner-ecr-public.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"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}/6d79089acf2375f6d13fb41fba9ce0ebfac06ddf21b1dccfbb19155dfee25760.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f00e06a7824495556404fb0a324a2b16e71836ea8aee2588858ad09bad6da100.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -65,6 +59,12 @@
]
},
"displayName": "integ-apprunner-ecr-public"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
}
},
"integ-apprunner-ecr-public": {
"id": "integ-apprunner-ecr-public",
"path": "integ-apprunner-ecr-public",
Expand All @@ -28,6 +20,7 @@
"aws:cdk:cloudformation:props": {
"sourceConfiguration": {
"authenticationConfiguration": {},
"autoDeploymentsEnabled": false,
"imageRepository": {
"imageConfiguration": {
"port": "8000"
Expand Down Expand Up @@ -59,20 +52,44 @@
"id": "URL1",
"path": "integ-apprunner-ecr-public/URL1",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"fqn": "@aws-cdk/core.CfnOutput",
"version": "0.0.0"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "integ-apprunner-ecr-public/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "integ-apprunner-ecr-public/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.252"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"fqn": "@aws-cdk/core.App",
"version": "0.0.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ const service1 = new Service(stack, 'Service1', {
},
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
}),
autoDeploymentsEnabled: false,
});
new cdk.CfnOutput(stack, 'URL1', { value: `https://${service1.serviceUrl}` });
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"31.0.0"}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "20.0.0",
"version": "31.0.0",
"files": {
"d21fee6f9384d15c5a0a826f4dbc23d103a989e9cc2e9c8abc2a629de9ea5cd2": {
"3f9deb43f8f02da8be7c2aa727a501250dbddc1fd19e848d488e7071380ce060": {
"source": {
"path": "integ-apprunner.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "d21fee6f9384d15c5a0a826f4dbc23d103a989e9cc2e9c8abc2a629de9ea5cd2.json",
"objectKey": "3f9deb43f8f02da8be7c2aa727a501250dbddc1fd19e848d488e7071380ce060.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
]
}
},
"AutoDeploymentsEnabled": true,
"ImageRepository": {
"ImageConfiguration": {
"Port": "8000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "31.0.0",
"testCases": {
"integ.service-ecr": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"version": "20.0.0",
"version": "31.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"integ-apprunner.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"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}/d21fee6f9384d15c5a0a826f4dbc23d103a989e9cc2e9c8abc2a629de9ea5cd2.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3f9deb43f8f02da8be7c2aa727a501250dbddc1fd19e848d488e7071380ce060.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -101,6 +95,12 @@
]
},
"displayName": "integ-apprunner"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Loading

0 comments on commit cf5a9c4

Please sign in to comment.