Skip to content

Commit

Permalink
chore(aws-apprunner): fix integration tests (#19660)
Browse files Browse the repository at this point in the history
splitting up the integration tests into separate tests so that we can
separate the ones that can be run and those that can't. The github test
requires a connection to github so it can't be run in automation.


----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [x] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
corymhall authored Apr 1, 2022
1 parent 9541de7 commit 4071d9b
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 201 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"Resources": {
"Service1EDCC8134": {
"Type": "AWS::AppRunner::Service",
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {},
"ImageRepository": {
"ImageConfiguration": {
"Port": "8000"
},
"ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest",
"ImageRepositoryType": "ECR_PUBLIC"
}
},
"InstanceConfiguration": {}
}
}
},
"Outputs": {
"URL1": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Fn::GetAtt": [
"Service1EDCC8134",
"ServiceUrl"
]
}
]
]
}
}
}
}
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as cdk from '@aws-cdk/core';
import { Service, Source } from '../lib';


const app = new cdk.App();

const stack = new cdk.Stack(app, 'integ-apprunner-ecr-public');

// Scenario 1: Create the service from ECR public
const service1 = new Service(stack, 'Service1', {
source: Source.fromEcrPublic({
imageConfiguration: {
port: 8000,
},
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
}),
});
new cdk.CfnOutput(stack, 'URL1', { value: `https://${service1.serviceUrl}` });
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
{
"Resources": {
"Service1EDCC8134": {
"Type": "AWS::AppRunner::Service",
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {},
"ImageRepository": {
"ImageConfiguration": {
"Port": "8000"
},
"ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest",
"ImageRepositoryType": "ECR_PUBLIC"
}
},
"InstanceConfiguration": {}
}
},
"Service2AccessRole759CA73D": {
"Service3AccessRole3ACBAAA0": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand All @@ -33,7 +17,7 @@
}
}
},
"Service2AccessRoleDefaultPolicy08C28479": {
"Service3AccessRoleDefaultPolicy57B9744E": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -66,37 +50,37 @@
{
"Ref": "AWS::AccountId"
},
":repository/nginx"
":repository/aws-cdk/assets"
]
]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "Service2AccessRoleDefaultPolicy08C28479",
"PolicyName": "Service3AccessRoleDefaultPolicy57B9744E",
"Roles": [
{
"Ref": "Service2AccessRole759CA73D"
"Ref": "Service3AccessRole3ACBAAA0"
}
]
}
},
"Service2AB4D14D8": {
"Service342D067F2": {
"Type": "AWS::AppRunner::Service",
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {
"AccessRoleArn": {
"Fn::GetAtt": [
"Service2AccessRole759CA73D",
"Service3AccessRole3ACBAAA0",
"Arn"
]
}
},
"ImageRepository": {
"ImageConfiguration": {
"Port": "80"
"Port": "8000"
},
"ImageIdentifier": {
"Fn::Join": [
Expand All @@ -113,7 +97,7 @@
{
"Ref": "AWS::URLSuffix"
},
"/nginx:latest"
"/aws-cdk/assets:77284835684772d19c95f4f5a37e7618d5f9efc40db9321d44ac039db457b967"
]
]
},
Expand All @@ -123,7 +107,7 @@
"InstanceConfiguration": {}
}
},
"Service3AccessRole3ACBAAA0": {
"Service2AccessRole759CA73D": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand All @@ -140,7 +124,7 @@
}
}
},
"Service3AccessRoleDefaultPolicy57B9744E": {
"Service2AccessRoleDefaultPolicy08C28479": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -181,29 +165,29 @@
],
"Version": "2012-10-17"
},
"PolicyName": "Service3AccessRoleDefaultPolicy57B9744E",
"PolicyName": "Service2AccessRoleDefaultPolicy08C28479",
"Roles": [
{
"Ref": "Service3AccessRole3ACBAAA0"
"Ref": "Service2AccessRole759CA73D"
}
]
}
},
"Service342D067F2": {
"Service2AB4D14D8": {
"Type": "AWS::AppRunner::Service",
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {
"AccessRoleArn": {
"Fn::GetAtt": [
"Service3AccessRole3ACBAAA0",
"Service2AccessRole759CA73D",
"Arn"
]
}
},
"ImageRepository": {
"ImageConfiguration": {
"Port": "8000"
"Port": "80"
},
"ImageIdentifier": {
"Fn::Join": [
Expand All @@ -229,89 +213,9 @@
},
"InstanceConfiguration": {}
}
},
"Service429949929": {
"Type": "AWS::AppRunner::Service",
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {
"ConnectionArn": "MOCK"
},
"CodeRepository": {
"CodeConfiguration": {
"ConfigurationSource": "REPOSITORY"
},
"RepositoryUrl": "https://github.com/aws-containers/hello-app-runner",
"SourceCodeVersion": {
"Type": "BRANCH",
"Value": "main"
}
}
},
"InstanceConfiguration": {}
}
},
"Service5AD92B5A5": {
"Type": "AWS::AppRunner::Service",
"Properties": {
"SourceConfiguration": {
"AuthenticationConfiguration": {
"ConnectionArn": "MOCK"
},
"CodeRepository": {
"CodeConfiguration": {
"CodeConfigurationValues": {
"BuildCommand": "yum install -y pycairo && pip install -r requirements.txt",
"Port": "8000",
"Runtime": "PYTHON_3",
"StartCommand": "python app.py"
},
"ConfigurationSource": "API"
},
"RepositoryUrl": "https://github.com/aws-containers/hello-app-runner",
"SourceCodeVersion": {
"Type": "BRANCH",
"Value": "main"
}
}
},
"InstanceConfiguration": {}
}
}
},
"Outputs": {
"URL1": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Fn::GetAtt": [
"Service1EDCC8134",
"ServiceUrl"
]
}
]
]
}
},
"URL2": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Fn::GetAtt": [
"Service2AB4D14D8",
"ServiceUrl"
]
}
]
]
}
},
"URL3": {
"Value": {
"Fn::Join": [
Expand All @@ -328,31 +232,15 @@
]
}
},
"URL4": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Fn::GetAtt": [
"Service429949929",
"ServiceUrl"
]
}
]
]
}
},
"URL5": {
"URL2": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Fn::GetAtt": [
"Service5AD92B5A5",
"Service2AB4D14D8",
"ServiceUrl"
]
}
Expand Down
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as path from 'path';
import * as assets from '@aws-cdk/aws-ecr-assets';
import * as cdk from '@aws-cdk/core';
import { Service, Source } from '../lib';


const app = new cdk.App();

const stack = new cdk.Stack(app, 'integ-apprunner');


// Scenario 3: Create the service from local code assets
const imageAsset = new assets.DockerImageAsset(stack, 'ImageAssets', {
directory: path.join(__dirname, './docker.assets'),
});
const service3 = new Service(stack, 'Service3', {
source: Source.fromAsset({
imageConfiguration: { port: 8000 },
asset: imageAsset,
}),
});
new cdk.CfnOutput(stack, 'URL3', { value: `https://${service3.serviceUrl}` });

// Scenario 2: Create the service from existing ECR repository
const service2 = new Service(stack, 'Service2', {
source: Source.fromEcr({
imageConfiguration: { port: 80 },
repository: imageAsset.repository,
tag: imageAsset.assetHash,
}),
});
new cdk.CfnOutput(stack, 'URL2', { value: `https://${service2.serviceUrl}` });
Loading

0 comments on commit 4071d9b

Please sign in to comment.