rights reserved. Who am I? 2 • Name • Kensuke Shimokawa • Company • Amazon Web Services Japan K.K. • Role • Serverless Specialist Solutions Architect @_kensh
rights reserved. Test Double 29 Test Double Dummy Stub Spy Mock Fake https://martinfowler.com/bliki/TestDouble.html Test Doubleは、テスト目的で本番オブジェクトを 置き換える場合の置き換えデザインパターンを表す用語です。 さまざまな種類のdoubleがあります。
rights reserved. Test Double 30 Test Double Dummy Stub Spy Mock Fake https://martinfowler.com/bliki/TestDouble.html Test Doubleは、テスト目的で本番オブジェクトを 置き換える場合の置き換えデザインパターンを表す用語です。 さまざまな種類のdoubleがあります。
rights reserved. AWS SAM CLI での Fake 45 1. ローカル起動用の Dummy Event データ生成 2. ローカルでLambdaを eventデータを指定して実行 SAM CLI $ sam local invoke -e event.json $ sam local generate-event \ apigateway aws-proxy \ --path datadog_report \ --method GET > event.json event.json
rights reserved. 49 3rd Party Fake https://localstack.cloud/ •API Gateway at http://localhost:4567 •Kinesis at http://localhost:4568 •DynamoDB at http://localhost:4569 •DynamoDB Streams at http://localhost:4570 •S3 at http://localhost:4572 •Firehose at http://localhost:4573 •Lambda at http://localhost:4574 •SNS at http://localhost:4575 •SQS at http://localhost:4576 •Redshift at http://localhost:4577 •Elasticsearch Service at http://localhost:4578 •SES at http://localhost:4579 •Route53 at http://localhost:4580 •CloudFormation at http://localhost:4581 •CloudWatch at http://localhost:4582 •SSM at http://localhost:4583 •SecretsManager at http://localhost:4584 •StepFunctions at http://localhost:4585 •CloudWatch Logs at http://localhost:4586 •EventBridge (CloudWatch Events) at http://localhost:4587 •STS at http://localhost:4592 •IAM at http://localhost:4593 •EC2 at http://localhost:4597 •KMS at http://localhost:4599
rights reserved. Multi Environment 63 デリバリーライフサイクルに応じて環境を個別に用意する Environment Development Pipeline Test Production Serverless Serviceはご利用分の従量課金 だから、環境分離に向いています
rights reserved. Environment Development Pipeline Test Production Multi Account 66 デリバリーライフサイクルに応じて AWS Account を個別に用意する Account Account Account Account
rights reserved. AWS Organizations を利用すると、Account管理が便利に 67 Organization Organization root OU AWS accounts Admin (master) AWS account AWS accounts AWS accounts OU OU OU OU https://www.slideshare.net/AmazonWebServicesJapan/20180214-aws-blackbeltorganizations
rights reserved. Cross Account Delivery Pipeline 69 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role IAM Role https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers
rights reserved. Cross Account Delivery Pipeline 70 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role Code Checkout IAM Role Assum e Role Put Code CodeCommitから CodeをCheckout https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers
rights reserved. Developers Cross Account Delivery Pipeline 71 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role Code Checkout IAM Role Assum e Role Put Code Trigger Sourceが checkout 完了したら、 CodeBuildを実⾏ https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/
rights reserved. Cross Account Delivery Pipeline 72 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role Code Checkout IAM Role Assum e Role Put Code Trigger Put Package Codeをビルドし、 PackageをS3にPutする https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers
rights reserved. Cross Account Delivery Pipeline 73 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role Code Checkout IAM Role Assum e Role Put Code Trigger Put Package Assum e Role Pass the Role CloudFormation 実⾏ Execute https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers
rights reserved. Cross Account Delivery Pipeline 74 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role Code Checkout IAM Role Assum e Role Put Code Trigger Put Package Assum e Role Pass the Role Execute https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers
rights reserved. Cross Account Delivery Pipeline 75 AWS Cloud AWS Cloud AWS Cloud AWS CodeCommit AWS CodeBuild AWS CodePipeline CloudFormation CloudFormation Stack Test Account Pipeline Account Development Account IAM Role Bucket IAM Role Code Checkout IAM Role Assum e Role Put Code Trigger Put Package Assum e Role Pass the Role Execute Cross Account でデリバリー完了! https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers
rights reserved. 実際にIntegration Test してみよう 76 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Integration Test 対象 サービス
rights reserved. 実際にIntegration Test してみよう 77 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Container Amazon Elastic Container Service テストシナリオを 配備しておく テスト実⾏⽤の リソースを確保
rights reserved. 実際にIntegration Test してみよう 78 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Container Amazon Elastic Container Service テストシナリオを 実⾏
rights reserved. 実際にIntegration Test してみよう 79 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Container Amazon Elastic Container Service テストシナリオを 実⾏ Cross Account でIntegration Test 完了!
rights reserved. Test のためのリソース維持やコストが気になる? 80 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Container Amazon Elastic Container Service テスト実⾏⽤の リソースを確保
rights reserved. Test のためのリソース維持やコストが気になる? 81 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Container Amazon Elastic Container Service テスト実⾏⽤の リソースを確保 Test 用のリソースも Serverlessで作るのは?
rights reserved. Test のためのリソース維持やコストが気になる? 82 AWS Cloud Test Account https://aws.amazon.com/jp/blogs/devops/aws-building-a-secure-cross-account-continuous-delivery-pipeline/ Developers AWS Cloud Development Account Container Amazon Elastic Container Service