EX) JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template",
"Resources": {
"MyEC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-0ff8a91507f77f867",
"InstanceType": "t2.micro",
"KeyName": "testkey",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sdm",
"Ebs": {
"VolumeType": "io1",
"Iops": 200,
"DeleteOnTermination": false,
"VolumeSize": 20
}
}
]
}
}
}
}
EX) YAML
AWSTemplateFormatVersion: 2010-09-09
Description: A sample template
Resources:
MyEC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: ami-0ff8a91507f77f867
InstanceType: t2.micro
KeyName: testkey
BlockDeviceMappings:
- DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: 200
DeleteOnTermination: false
VolumeSize: 20
템플릿을 수정하고 로컬이나 S3 버킷에 저장을 하면 CloudFormation에서 변경점을 발견한다.
변경점을 발견하면 CloudFormation이 스택을 갱신시키고, 갱신된 스택을 업데이트 한다.
#Step 1 - 샘플 애플리케이션 다운로드
sam init
#Step 2 - 애플리케이션 빌드
cd sam-app
sam build
#Step 3 - 애플리케이션 배포
sam deploy --guided
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
LambdaFunctionOverHttps:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs18.x
Policies: AmazonDynamoDBFullAccess
Events:
HttpPost:
Type: Api
Properties:
Path: '/DynamoDBOperations/DynamoDBManager'
Method: post