-
Notifications
You must be signed in to change notification settings - Fork 0
/
CI-CD-roles.yml
144 lines (132 loc) · 4.16 KB
/
CI-CD-roles.yml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
AWSTemplateFormatVersion: "2010-09-09"
Description: CSYE 6225 IaC
Parameters:
RoleName:
Description: "Name of the IAM role for CI/CD actions"
Type: String
Default: "ghactions-app"
# AWS_Region:
# Description: "AWS region"
# Type: String
# Default: "us-east-1"
# AWS_ID:
# Description: "AWS ID"
# Type: String
# Default: "909665281672"
Resources:
myGHCodedeployBucketPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: GH-Upload-To-S3
PolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Action:
- s3:PutObject
- s3:Get*
- s3:List*
Resource:
- Fn::Join:
- ""
- - "arn:aws:s3:::"
- "codedeploy.applicationbhan.me"
- "/*"
- Fn::Join:
- ""
- - "arn:aws:s3:::"
- "codedeploy.applicationbhan.me"
Users:
- !Ref RoleName
myGHCodedeployPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: GH-Code-deploy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- codedeploy:RegisterApplicationRevision
- codedeploy:GetApplicationRevision
Resource:
- "arn:aws:codedeploy:us-east-1:909665281672:application:csye6225-webapp"
- Effect: Allow
Action:
- codedeploy:CreateDeployment
- codedeploy:GetDeployment
Resource:
- "*"
- Effect: Allow
Action:
- codedeploy:GetDeploymentConfig
Resource:
- "arn:aws:codedeploy:us-east-1:909665281672:deploymentconfig:CodeDeployDefault.OneAtATime"
- "arn:aws:codedeploy:us-east-1:909665281672:deploymentconfig:CodeDeployDefault.HalfAtATime"
- "arn:aws:codedeploy:us-east-1:909665281672:deploymentconfig:CodeDeployDefault.AllAtOnce"
Users:
- !Ref RoleName
myGHCodedeployEC2Policy:
Type: AWS::IAM::Policy
Properties:
PolicyName: GH-ec2-ami
PolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Action:
- ec2:AttachVolume
- ec2:AuthorizeSecurityGroupIngress
- ec2:CopyImage
- ec2:CreateImage
- ec2:CreateKeypair
- ec2:CreateSecurityGroup
- ec2:CreateSnapshot
- ec2:CreateTags
- ec2:CreateVolume
- ec2:DeleteKeyPair
- c2:DeleteSecurityGroup
- ec2:DeleteSnapshot
- ec2:DeleteVolume
- ec2:DeregisterImage
- ec2:DescribeImageAttribute
- ec2:DescribeImages
- ec2:DescribeInstances
- ec2:DescribeInstanceStatus
- ec2:DescribeRegions
- ec2:DescribeSecurityGroups
- ec2:DescribeSnapshots
- ec2:DescribeSubnets
- ec2:DescribeTags
- ec2:DescribeVolumes
- ec2:DetachVolume
- ec2:GetPasswordData
- ec2:ModifyImageAttribute
- ec2:ModifyInstanceAttribute
- ec2:ModifySnapshotAttribute
- ec2:RegisterImage
- ec2:RunInstances
- ec2:StopInstances
- ec2:TerminateInstances
Resource:
- "*"
Users:
- !Ref RoleName
myGHLambdaDeploymentPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: GH-Deploy-to-Lambda
PolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Action:
- s3:PutObject
- iam:ListRoles
- lambda:UpdateFunctionCode
- lambda:CreateFunction
- lambda:UpdateFunctionConfiguration
Resource:
- "arn:aws:lambda:us-east-1:909665281672:function:verification-email-service"
Users:
- !Ref RoleName