-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfrastructure-stack.yml
More file actions
98 lines (98 loc) · 2.87 KB
/
Copy pathinfrastructure-stack.yml
File metadata and controls
98 lines (98 loc) · 2.87 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
87
88
89
90
91
92
93
94
95
96
97
98
AWSTemplateFormatVersion: 2010-09-09
Description: >-
This template creates:
- CFNUserGroup and CFNAdminGroup IAM groups. Note that
CFNAdminGroup has full admin powers!
- CFNUser IAM user associated with both of these groups
- a policy, role and associated instance profile which allow an
EC2 instances to access S3 buckets.
- a new ElasticIp (EIP).
Note that you will need to specify the CAPABILITY_IAM flag when you
create the stack to allow this template to execute.
Parameters:
ECRRepositoryName:
Description: Name of the codecommit and ECR repos for this project
Default: data-science-stack-ecr-repo
Type: String
CodeCommitRepositoryName:
Description: Name of the codecommit and ECR repos for this project
Default: data-science-stack-cc-repo
Type: String
S3BucketName:
Description: Name of the S3 bucket which will hold job outputs
Default: data-science-stack-outputs
Type: String
ImageTag:
Description: Tag for the docker image
Default: data-science-image
Type: String
Resources:
CodeCommitRepo:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryDescription: Repo to allow EC2 access to the DataScienceStack environment.
RepositoryName: !Ref CodeCommitRepositoryName
InstanceECR:
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Ref ECRRepositoryName
ListS3BucketsInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref ListS3BucketsRole
ListS3BucketsPolicy:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: ListS3BucketsPolicy
PolicyDocument:
Statement:
- Effect: Allow
Action:
- 's3:*'
- 'codecommit:*'
- 'ecr:*'
- 'ec2:*'
Resource: '*'
- Effect: Allow
Action:
- 'cloudformation:DeleteStack'
Resource: '*'
Roles:
- !Ref ListS3BucketsRole
ListS3BucketsRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref S3BucketName
DeletionPolicy: Delete
Outputs:
InstanceRole:
Value: !Ref ListS3BucketsInstanceProfile
Export:
Name: "InstanceProfile::S3Access"
S3BucketName:
Value: !Ref S3BucketName
Export:
Name: "S3BucketName"
CodeCommitAddress:
Value: !GetAtt CodeCommitRepo.CloneUrlHttp
Export:
Name: "CodeCommitAddress"
ImageTag:
Value: !Join [ "", [ !Ref "AWS::AccountId", ".dkr.ecr.", !Ref "AWS::Region", ".amazonaws.com/", !Ref "ImageTag" ] ]
Export:
Name: "ImageTagExport"