-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathartifact-bucket.yaml
84 lines (71 loc) · 2.2 KB
/
artifact-bucket.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
---
AWSTemplateFormatVersion: 2010-09-09
Description: >
This template deploys an S3 bucket for storing artifacts from the build
pipeline
Parameters:
AppName:
Type: String
Description: Name of the application.
MinLength: "1"
MaxLength: "80"
AllowedPattern: "[A-Za-z0-9-]+"
ConstraintDescription: Malformed input parameter. AppName must only contain upper and lower case letters, numbers, and -.
CodePipelineRoleName:
Type: String
Description: Role name the pipeline will use
CodeBuildRoleName:
Type: String
Description: Role name for code build
LambdaDeployRoleName:
Type: String
Description: Role name for code build
Resources:
artifactS3Bucket:
Description: Creating Amazon S3 bucket for AWS CodePipeline artifacts
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: !Sub "${AWS::AccountId}-${AWS::Region}-${AppName}"
VersioningConfiguration:
Status: Enabled
artifactS3BucketPolicy:
Description: Setting Amazon S3 bucket policy for AWS CodePipeline access
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref artifactS3Bucket
PolicyDocument:
Version: "2012-10-17"
Id: SSEAndSSLPolicy
Statement:
- Sid: DenyInsecureConnections
Effect: Deny
Principal: "*"
Action: s3:*
Resource: !Sub "arn:aws:s3:::${artifactS3Bucket}/*"
Condition:
Bool:
aws:SecureTransport: false
artifactS3BucketAccessPolicy:
Description: Setting IAM policy to allow full access to artifact bucket
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ${AppName}-Access${artifactS3Bucket}Bucket-${AWS::Region}
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- S3:GetObjectVersion
Resource:
- !Sub "arn:aws:s3:::${artifactS3Bucket}/*"
Roles:
- !Ref CodePipelineRoleName
- !Ref CodeBuildRoleName
- !Ref LambdaDeployRoleName
Outputs:
ArtifactS3BucketName:
Value: !Ref artifactS3Bucket
ArtifactS3BucketArn:
Value: !GetAtt artifactS3Bucket.Arn