Share
Embed
Transcript
47 slides
-
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with 2 0 - 2 2 . 1 0 . 2 0 2 0 -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with CDK @hixi-hyi F - 9 -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with T?R/ E<=2 @hixi-hyi 2013@HB1P-,#,-G93P -&+&( %-'-$!+" :JI0 &),(!- SY N;P4KF+"WX C> 7J6A5ODV+*,- ,+%( 7JM8. Cloudformation 5O CDK ))-L CDK QU -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with ,! 4#% • 3$ (-)4 • "02! .651 7*/ • !#%8. ! +'!& -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with CDK • id • -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with cdk init cdk init app --language=typescript aws-cdk-bestpractice -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with cdk init cdk init app --language=typescript aws-cdk-bestpractice bin/aws-cdk-bestpractice.ts const app = new cdk.App(); new AwsCdkBestpracticeStack(app, 'AwsCdkBestpracticeStack’); -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with cdk init cdk init app --language=typescript aws-cdk-bestpractice bin/aws-cdk-bestpractice.ts const app = new cdk.App(); new AwsCdkBestpracticeStack(app, 'AwsCdkBestpracticeStack’); lib/aws-cdk-bestpractice.ts export class AwsCdkBestpracticeStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, …) { super(scope, id, props); } } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with cdk init cdk init app --language=typescript aws-cdk-bestpractice bin/aws-cdk-bestpractice.ts const app = new cdk.App(); new AwsCdkBestpracticeStack(app, 'AwsCdkBestpracticeStack’); lib/aws-cdk-bestpractice.ts export class AwsCdkBestpracticeStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, …) { super(scope, id, props); } } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with ! • VOHN%2T/(0&'*+%AS VOHN,.-0)%1 U4" • /(0&ASW"PB human readable ;9% /(0&K F?5%JD construct 37MCE$#" I<I<F?5%>U K " "LX /(0&F?8R@= " #%1 6G "Q: -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with id - const id = new cdkid.Identifier({ section: resolveEnvironmentFromAwsAccountId(), }); const app = new cdk.App(); id.child({legion: "product"}).scope((id: cdkid.Identifier) => { id.child({cohort: "service"}).scope((id: cdkid.Identifier) => { new stack.ProductServiceApi(app, id.child({family: 'api'})); }); }); export class ProductServiceApi extends cdk.Stack { constructor(app: cdk.App, id: cdkid.Identifier, props: ProductServiceApiProps) { ... } } https://github.com/hixi-hyi/aws-cdk-identifier -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with id - export class ProductServiceApi extends cdk.Stack { constructor(app: cdk.App, id: cdkid.Identifier, props: ProductServiceApiProps) { super(app, id.stackName, props); const fargate = new construct.Fargate(this, id.child("Aurora"), { maxCapacity: cdkid.Variables.resolve(id, cdkid.RankLoc.Section, { dev: 1, prod: 10, }), }); } https://github.com/hixi-hyi/aws-cdk-identifier -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with id - export class Fargate extends cdk.Construct { constructor(app: cdk.Construct, id: cdkid.Identifier, props: FargateProps) { super(app, id.constructName); const cluster = new ecs.Cluster(this, 'Cluster’, { clusterName: id.camelName, ... }); ... } https://github.com/hixi-hyi/aws-cdk-identifier Construct -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with id - +α const patterns = new ecsPatterns.ApplicationLoadBalancedFargateService(this, “Service”, { ... taskImageOptions: { environment: { ‘IAC_CORE_SECTION’: id.rank.section, // dev or prod }, }, }); https://github.com/hixi-hyi/aws-cdk-identifier -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with id -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with • #!"$ • ! -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with &/) • 7' 13(4%-.8 • *0#2 $,13( !"56 • • + -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with ├── bin │ └── infra.ts └── lib ├── @aws-cdk/ ├── construct/ ├── helper/ └── stack/ -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with &# ├── bin │ └── infra.ts (lib/stack stack ! "+ ) └── lib ├── @aws-cdk (cdk % ) ) ├── construct (,) L2/patterns construct "+ ) ├── helper ( ('* $ "+ ) └── stack (lib/construct ! "+ ) -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with bin/infra.ts id = cdkid.Identifier({ section: resolveEnvironmentFromAwsAccountId() }); const common = new stack.ProductCommon(app, id); new stack.ProductServiceApi(app, id.child({cohort: “service”, family: 'api'}), { common }); -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/stack/* export class ProductServiceApi extends cdk.Stack { constructor(app: cdk.App, id: cdkid.Identifier, props: ProductServiceApiProps) { super(app, id.stackName, props); } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/stack/* export class ProductServiceApi extends cdk.Stack { constructor(app: cdk.App, id: cdkid.Identifier, props: ProductServiceApiProps) { super(app, id.stackName, props); const ecr = new construct.Ecr(this, id.child('Repository’)); } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/stack/* export class ProductServiceApi extends cdk.Stack { constructor(app: cdk.App, id: cdkid.Identifier, props: ProductServiceApiProps) { super(app, id.stackName, props); const ecr = new construct.Ecr(this, id.child('Repository’)); const fargate = new construct.FargateL7Webapp(this, id.child('Webapp'), { ... image: ecs.ContainerImage.fromEcrRepository(ecr.repository), maxCapacity: cdkid.Variables.resolve(id, cdkid.RankLoc.Section, { dev : 1, prod: 10, }), }); ... } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/stack/* export class ProductServiceApi extends cdk.Stack { constructor(app: cdk.App, id: cdkid.Identifier, props: ProductServiceApiProps) { super(app, id.stackName, props); const ecr = new construct.Ecr(this, id.child('Repository’)); const fargate = new construct.FargateL7Webapp(this, id.child('Webapp'), { ... image: ecs.ContainerImage.fromEcrRepository(ecr.repository), maxCapacity: cdkid.Variables.resolve(id, cdkid.RankLoc.Section, { dev : 1, prod: 10, }), }); ... } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/construct/* -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/@aws-cdk/* https://github.com/aws/aws-cdk/issues/9926 https://github.com/aws/aws-cdk/pull/10324 -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with lib/helper/* export function LogGroupRetentionDay(id: cdkid.Identifier): logs.RetentionDays { return cdkid.Variables.resolve<logs.RetentionDays>(id, cdkid.RankLoc.Section, { dev: logs.RetentionDays.TWO_WEEKS, prod: logs.RetentionDays.INFINITE, }) } -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with *'&1 ├── bin │ └── infra.ts (lib/stack ! stack $ %/ ) └── lib ├── @aws-cdk (cdk #) - ) ├── construct (0- L2/patterns construct %/ ) ├── helper ( ,"+. #( %/ ) └── stack (lib/construct ! $ %/ ) -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with • id )-$ • )& %",# (' )&* ! + https://github.com/hixi-hyi/aws-cdk-bestpractice -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with Q1. L1 L2 L2 -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with Q1. L1 + L2 + *% &"$ # ) !' lib/@aws-cdk ( PR -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with Q2. -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with Q1. cdk diff -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with -
© 2020, Amazon Web Services, Inc. or its affiliates. All
rights reserved. In Partnership with Q3. IaC ,9 814)* )+3 !%02&'7 • 81-%8145/ IAM Policy .' • SSM Parameters /service/xxx/app/* #"8145/6$( • !81 Dockerfile -
Thank you! © 2020, Amazon Web Services, Inc. or its
affiliates. All rights reserved. In Partnership with CDK • id • https://github.com/hixi-hyi/aws-cdk-bestpractice