CloudFormationでS3デプロイする – 【CloudFormation】
CloudFormationでS3デプロイするyamlです。
S3
S3バケットデプロイ用template.yamlです。
template.yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: This CloudFormation template to create Lambda function
Resources:
S3Bucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: "test-bucket" # bucketname
ウェブアクセス公開用S3
ウェブアクセス公開用のS3バケットをデプロイします。
「AWS::S3::BucketPolicy」の設定が必要になります。
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: This CloudFormation template to create Lambda function
Resources:
# S3 bucket
S3Bucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: "test-bucket" # bucketname
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
OwnershipControls:
Rules:
- ObjectOwnership: ObjectWriter
# Bucket Policy
BucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket: !Ref S3Bucket
PolicyDocument:
Statement:
- Effect: Allow
Principal: '*'
Action: 's3:GetObject'
Resource: !Sub ${S3Bucket.Arn}/*
sam deploy
コマンドプロンプトからデプロイします。ここではスタック名はmystackにしています。
sam deploy --template-file template.yaml --resolve-s3 ^ --stack-name mystack --capabilities CAPABILITY_NAMED_IAM ^ --no-fail-on-empty-changeset --region ap-northeast-1
ドキュメント
ERROR: The request could not be satisfied
ERROR: The request could not be satisfied
ERROR: The request could not be satisfied

KHI入社して退社。今はCONFRAGEで正社員です。関西で140-170/80~120万から受け付けております^^
得意技はJS(ES20xx),Java,AWSの大体のリソースです
コメントはやさしくお願いいたします^^
座右の銘は、「狭き門より入れ」「願わくは、我に七難八苦を与えたまえ」です^^


コメント