-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yaml
110 lines (102 loc) · 3.04 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: amazon-ebs-migration-utility
Description: Amazon EBS Volume Migration Utility
Author: Sanjay Dhar
SpdxLicenseId: MIT-0
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: ['gp2', 'gp3', 'EBS']
HomePageUrl: https://github.com/sanjdhar/amazon-ebs-migration-utility
SemanticVersion: 1.0.0
SourceCodeUrl: https://github.com/sanjdhar/amazon-ebs-migration-utility
Parameters:
TargetEmail:
Type: String
Description: Enter a valid email address for notifications (Required)
ConstraintDescription: You should enter a valid email address for notifications (Required)
Resources:
LambdaRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "lambda.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
RolePolicies:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: "ebsconverter-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: "arn:aws:logs:*:*:*"
- Effect: Allow
Action:
- sns:Publish
Resource: !Ref EBSConvSNS
- Effect: Allow
Action:
- iam:GetRole
- iam:ListRoles
- kms:DescribeKey
- kms:GetKeyPolicy
- kms:ListGrants
- kms:ListKeyPolicies
- kms:ListKeys
- ec2:DescribeTags
- ec2:DescribeVolumeAttribute
- ec2:DescribeVolumeStatus
- ec2:DescribeVolumes
- ec2:DescribeVolumesModifications
- ec2:ModifyVolume
- ec2:ModifyVolumeAttribute
Resource: "*"
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource: !GetAtt EBSVolumeTable.Arn
Roles:
- Ref: "LambdaRole"
EBSConvSNS:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Endpoint: !Ref TargetEmail
Protocol: 'email'
EBSVolumeConverter:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: amazon-ebs-migration-utility
S3Key: gp3_upgrade.zip
Handler: gp3_upgrade.lambda_handler
Runtime: python3.7
Timeout: 120
MemorySize: 128
Role: !GetAtt LambdaRole.Arn
Environment:
Variables:
DDB_TABLE_NAME: !Ref EBSVolumeTable
SNS_ARN: !Ref EBSConvSNS
EBSVolumeTable:
Type: 'AWS::Serverless::SimpleTable'
Properties:
PrimaryKey:
Name: volume_id
Type: String