CloudFormation is one of AWS service, which allows you to set up and manage AWS resources via a template. It allows you to create and manage your infrastructure as code. It is also easy to deploy or destroy any resources, by creating a stack or deleting it.
Template: An CloudFormation template is a JSON or YAML file, which uses as blueprints for building AWS resources.
Stack: CloudFormation manage resources as a single unit called a Stack.
Resources:
EventTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Event-Table
AttributeDefinitions:
- AttributeName: "event"
AttributeType: "S"
KeySchema:
- AttributeName: "event"
KeyType: "HASH"
TimeToLiveSpecification:
AttributeName: "ExpirationTime"
Enabled: true
ProvisionedThroughput:
ReadCapacityUnits: "10"
WriteCapacityUnits: "10"
DependsOn:
- DynamoDBQueryPolicy
DynamoDBQueryPolicy:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: DynamoDBQueryPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "dynamodb:Query"
Resource: "*"
Roles:
- Ref: "EventQueryRole"
EventQueryRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "dynamodb.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
Stay up-to-date with new posts