-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an ECR repo to Finch infrastructure. this repository is where the image used as the basis for the Finch VM rootfs will live. Signed-off-by: Gavin Inglis <giinglis@amazon.com>
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { CfnOutput } from 'aws-cdk-lib'; | ||
import * as ecr from 'aws-cdk-lib/aws-ecr'; | ||
import { Construct } from 'constructs'; | ||
|
||
export class ECRRepositoryStack extends cdk.Stack { | ||
public readonly repositoryOutput: CfnOutput; | ||
public readonly repository: ecr.Repository; | ||
constructor(scope: Construct, id: string, stage: string, props?: cdk.StackProps) { | ||
super(scope, id, props); | ||
const repoName = `finch-rootfs-image-${stage.toLowerCase()}`; | ||
const ecrRepository = new ecr.Repository(this, 'finch-rootfs', { | ||
repositoryName:repoName, | ||
imageTagMutability: ecr.TagMutability.IMMUTABLE, | ||
// TODO: CFN does not provide APIs for enhanced image scanning. | ||
// create a custom stack that uses the AWS sdk to change the account ECR | ||
// scanning settings to enhanced. | ||
imageScanOnPush: true, | ||
}); | ||
|
||
this.repository = ecrRepository | ||
this.repositoryOutput = new CfnOutput(this, 'ECR repository', { value: ecrRepository.repositoryName }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { Template, Match } from 'aws-cdk-lib/assertions'; | ||
import { ECRRepositoryStack } from '../lib/ecr-repo-stack'; | ||
|
||
describe('ECRRepositoryStack', () => { | ||
test('synthesizes the way we expect', () => { | ||
const app = new cdk.App(); | ||
const ecrRepo = new ECRRepositoryStack(app, 'ECRRepositoryStack', 'test'); | ||
|
||
// prepare the ECRRepositoryStack template for assertions | ||
const template = Template.fromStack(ecrRepo); | ||
|
||
// assert it creates the ecr repo with properties set. | ||
template.resourceCountIs('AWS::ECR::Repository', 1); | ||
template.hasResource('AWS::ECR::Repository', { | ||
Properties: { | ||
RepositoryName: Match.anyValue(), | ||
ImageTagMutability: "IMMUTABLE", | ||
ImageScanningConfiguration: { | ||
ScanOnPush: true, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}) |