-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArm-VHT-CloudFormation-Template.yaml
124 lines (124 loc) · 3.05 KB
/
Arm-VHT-CloudFormation-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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
AWSTemplateFormatVersion: 2010-09-09
Parameters:
S3BucketName:
Type: String
Description: VHT S3 Bucket. Name must be unique.
VpcId:
Type: String
Description: VPC ID to be associated with the VHT Security Group (e.g. vpc-0dc320e47b6a8077f)
Resources:
VHTS3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
AccessControl: Private
BucketName:
Ref: S3BucketName
Tags:
- Key: VHT
Value: true
VHTEC2SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow ssh communication and outbound traffic
GroupName: VHTEC2SecurityGroup
VpcId:
Ref: VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
VHTIAMProfile:
Type: "AWS::IAM::InstanceProfile"
Properties:
InstanceProfileName: VHTRole
Path: "/"
Roles:
- Ref: "VHTRole"
DependsOn:
- VHTRole
VHTPassrole:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: VHTPassRole
PolicyDocument: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "*"
}
]
}
Users:
- VHTUser
DependsOn: VHTUser
VHTRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Description: Allows EC2 instances to call AWS services on VHT behalf.
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonS3FullAccess
- arn:aws:iam::aws:policy/AmazonSSMFullAccess
RoleName: VHTRole
Tags:
- Key: VHT
Value: true
VHTUser:
Type: 'AWS::IAM::User'
Properties:
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonEC2FullAccess'
- 'arn:aws:iam::aws:policy/AmazonS3FullAccess'
- 'arn:aws:iam::aws:policy/AmazonSSMFullAccess'
UserName: VHTUser
Tags:
- Key: VHT
Value: true
VHTUserAccessKey:
Type: AWS::IAM::AccessKey
Properties:
Status: Active
UserName: VHTUser
DependsOn: VHTUser
Outputs:
VHTIAMProfile:
Value:
!Ref VHTIAMProfile
Description:
IAM Instance Profile created in the stack
VHTAccessKeyId:
Value:
!Ref VHTUserAccessKey
Description:
Access Key Id for the created IAM User
VHTSecretAccessKey:
Value:
!GetAtt VHTUserAccessKey.SecretAccessKey
Description:
Secret Access Key for the created IAM User
VHTS3BucketName:
Value:
!Ref S3BucketName
Description:
S3 Bucket created in the stack
VHTEC2SecurityGroupId:
Value:
!GetAtt VHTEC2SecurityGroup.GroupId
Description:
EC2 Security Group created in the stack