Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS環境でIaCを使い始めて運用するためのメリットデメリットと注意点

mokonist
June 26, 2020

 AWS環境でIaCを使い始めて運用するためのメリットデメリットと注意点

mokonist

June 26, 2020
Tweet

More Decks by mokonist

Other Decks in Technology

Transcript

  1. 2 ⾃⼰紹介 もこ クラスメソッド株式会社 AWS事業本部 コンサルティング部ソリューションアーキテクト 2020 APN AWS Top

    Engineers 現職: Terraform/CDKでAWS環境の構築 前職: ECサイトのSREっぽい事 好き: アプリとインフラの中間、TypeScript 好きなAWSサービス: ECS/Amplify/CDK Twitter/GitHub: mokocm
  2. 22 Terraform // vpc resource "aws_vpc" "vpc" { cidr_block =

    "10.0.0.0/16" } // igw resource "aws_internet_gateway" "igw" { vpc_id = aws_vpc.vpc.id } // subnet (a) resource "aws_subnet" "subnet_a" { cidr_block = "10.0.0.0/24" vpc_id = aws_vpc.vpc.id availability_zone = "ap-northeast-1a" } // subnet (c) resource "aws_subnet" "subnet_c" { cidr_block = "10.0.0.1/24" vpc_id = aws_vpc.vpc.id availability_zone = "ap-northeast-1c" }
  3. 23 Terraform // Route Table(0.0.0.0/0 igw) resource "aws_route_table" "public" {

    vpc_id = aws_vpc.vpc.id route { cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.igw.id } } // RouteTableにAssociation resource "aws_route_table_association” "subnet_a" { route_table_id = aws_route_table.public.id subnet_id = aws_subnet.subnet_a.id } resource "aws_route_table_association" "subnet_c" { route_table_id = aws_route_table.public.id subnet_id = aws_subnet.subnet_c.id }
  4. 26 CDK import { Stack, Construct, StackProps, Duration } from

    '@aws-cdk/core'; import { Vpc } from '@aws-cdk/aws-ec2’ export class SlackTranslateBotStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); const vpc = new Vpc(this, 'TheVPC', { cidr: "10.0.0.0/16" }) } }
  5. 28 CDK https://dev.classmethod.jp/articles/aws-cdk-serverless-develop/ CDK + Lambdaで開発がめちゃめちゃ捗る︕ constructor(scope: Construct, id: string,props?:StackProps)

    { super(scope, id, props); const lambda = new NodejsFunction(this, 'lambda', { entry: 'lambda/app.ts’, handler: 'handler’, runtime: Runtime.NODEJS_12_X, timeout: Duration.minutes(5) }); const api = new LambdaRestApi(this, 'api', { handler: lambda }); }
  6. 46