forked from nilan3/cloudformation-ec2-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcfn-setup-stack.yml
More file actions
86 lines (79 loc) · 2.21 KB
/
cfn-setup-stack.yml
File metadata and controls
86 lines (79 loc) · 2.21 KB
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
AWSTemplateFormatVersion: 2010-09-09
Description: Set up cloudformation requirements
Parameters:
Version:
Type: String
Default: "0.0.1"
Description: Version of the application
Environment:
Type: String
Default: dev
Description: Select the appropriate environment
AllowedValues:
- dev
- staging
- prod
S3CfnBucketName:
Type: String
Default: aws-cloudformation-templates
Resources:
TemplatesBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "${S3CfnBucketName}-${Environment}-${AWS::Region}"
VersioningConfiguration:
Status: Enabled
AccessControl: Private
Tags:
- Key: Name
Value: !Sub "${S3CfnBucketName}-${Environment}-${AWS::Region}"
- Key: Version
Value: !Ref Version
- Key: Environment
Value: !Ref Environment
CloudFormationServiceRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: AWSCloudFormationServiceRole
AssumeRolePolicyDocument:
Statement:
-
Effect: "Allow"
Principal:
Service:
- "cloudformation.amazonaws.com"
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
-
Effect: "Allow"
Principal:
AWS:
- !Sub "arn:aws:iam::${AWS::AccountId}:root"
Action:
- "sts:AssumeRole"
Path: "/"
Policies:
-
PolicyName: "AmazonCloudFormationServiceRolePolicy"
PolicyDocument:
Statement:
-
Effect: "Allow"
Action: "*"
Resource: "*"
Outputs:
TemplatesBucketName:
Value: !Ref TemplatesBucket
Export:
Name: !Sub "${AWS::StackName}-TemplatesBucketName"
TemplatesBucketArn:
Value: !GetAtt TemplatesBucket.Arn
Description: ARN of the templates bucket
Export:
Name: !Sub "${AWS::StackName}-TemplatesBucketArn"
CloudFormationServiceRole:
Description: "Policy to Allow Cloudformation Full Access AWS to Resources"
Value: !Ref "CloudFormationServiceRole"
Export:
Name: !Sub "${AWS::StackName}-CloudFormationServiceRole"