AnimeshShaw commited on
Commit
7d2d02b
·
1 Parent(s): 9676a90

Add human_reference_dataset/aws-cloudformation-templates/RainModules/

Browse files
human_reference_dataset/aws-cloudformation-templates/RainModules/README.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Rain Modules
2
+
3
+ These files are used by [CloudFormation
4
+ Rain](https://github.com/aws-cloudformation/rain) to inject re-useable code
5
+ into templates with the `!Rain::Module` directive.
6
+
7
+ They have a `.yml` extension instead of a `.yaml` extension to exclude them
8
+ from automation like formatting and linting.
9
+
10
+
human_reference_dataset/aws-cloudformation-templates/RainModules/api-resource.yml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Description: This module contains a lambda handler and the API Gateway resource to proxy requests to the lambda. It is assumed that the lambda function can handle all HTTPMethods sent to the specified path, including the OPTIONS pre-flight request. The lambda function must also return the approppriate CORS headers with each response.
2
+
3
+ Parameters:
4
+
5
+ Name:
6
+ Type: String
7
+ Description: This name will be used for resource names and tags
8
+
9
+ RestApi:
10
+ Type: String
11
+
12
+ RestApiDeployment:
13
+ Type: String
14
+
15
+ BuildScript:
16
+ Type: String
17
+ Description: The name of the script to run before uploading the lambda handler to S3
18
+
19
+ CodePath:
20
+ Type: String
21
+ Description: The path of the packaged lambda function created by BuildScript
22
+
23
+ ResourcePath:
24
+ Type: String
25
+ Description: The URI path name for the resource, for example, "user" or "order"
26
+
27
+ AuthorizerId:
28
+ Type: String
29
+ Description: The Id of the APIGateway Authorizer
30
+
31
+ Resources:
32
+
33
+ Handler:
34
+ Type: AWS::Lambda::Function
35
+ Properties:
36
+ Handler: bootstrap
37
+ FunctionName: !Sub ${Name}-handler
38
+ Runtime: provided.al2023
39
+ Code: !Rain::S3
40
+ Run: !Ref BuildScript
41
+ Zip: false
42
+ Path: !Ref CodePath
43
+ KeyProperty: S3Key
44
+ BucketProperty: S3Bucket
45
+ Role: !GetAtt HandlerRole.Arn
46
+
47
+ HandlerRole:
48
+ Type: AWS::IAM::Role
49
+ Properties:
50
+ AssumeRolePolicyDocument:
51
+ Version: '2012-10-17'
52
+ Statement:
53
+ - Effect: Allow
54
+ Principal:
55
+ Service:
56
+ - lambda.amazonaws.com
57
+ Action:
58
+ - 'sts:AssumeRole'
59
+ ManagedPolicyArns:
60
+ - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
61
+
62
+ Resource:
63
+ Type: AWS::ApiGateway::Resource
64
+ Properties:
65
+ ParentId: !Sub ${RestApi.RootResourceId}
66
+ PathPart: !Ref ResourcePath
67
+ RestApiId: !Ref RestApi
68
+
69
+ Permission:
70
+ Type: AWS::Lambda::Permission
71
+ Properties:
72
+ Action: lambda:InvokeFunction
73
+ FunctionName: !GetAtt Handler.Arn
74
+ Principal: apigateway.amazonaws.com
75
+ SourceArn: !Sub "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${RestApi}/*/*/*"
76
+
77
+ RootPermission:
78
+ Type: AWS::Lambda::Permission
79
+ Properties:
80
+ Action: lambda:InvokeFunction
81
+ FunctionName: !GetAtt Handler.Arn
82
+ Principal: apigateway.amazonaws.com
83
+ SourceArn: !Sub "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${RestApi}/*/*/"
84
+
85
+ Options:
86
+ Type: AWS::ApiGateway::Method
87
+ Properties:
88
+ HttpMethod: OPTIONS
89
+ ResourceId: !Ref Resource
90
+ RestApiId: !Ref RestApi
91
+ AuthorizationType: NONE
92
+ Integration:
93
+ IntegrationHttpMethod: POST
94
+ Type: AWS_PROXY
95
+ Uri: !Sub "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Handler.Arn}/invocations"
96
+
97
+ Get:
98
+ Type: AWS::ApiGateway::Method
99
+ Properties:
100
+ HttpMethod: GET
101
+ ResourceId: !Ref Resource
102
+ RestApiId: !Ref RestApi
103
+ AuthorizationType: COGNITO_USER_POOLS
104
+ AuthorizerId: !Ref AuthorizerId
105
+ Integration:
106
+ IntegrationHttpMethod: POST
107
+ Type: AWS_PROXY
108
+ Uri: !Sub "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Handler.Arn}/invocations"
109
+
110
+
111
+
human_reference_dataset/aws-cloudformation-templates/RainModules/bucket-policy.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Parameters:
2
+ PolicyBucketName:
3
+ Type: String
4
+ Resources:
5
+ Policy:
6
+ Type: AWS::S3::BucketPolicy
7
+ Properties:
8
+ Bucket: !Ref PolicyBucketName
9
+ PolicyDocument:
10
+ Statement:
11
+ - Action: s3:*
12
+ Condition:
13
+ Bool:
14
+ aws:SecureTransport: false
15
+ Effect: Deny
16
+ Principal:
17
+ AWS: '*'
18
+ Resource:
19
+ - !Sub "arn:${AWS::Partition}:s3:::${PolicyBucketName}"
20
+ - !Sub "arn:${AWS::Partition}:s3:::${PolicyBucketName}/*"
21
+ - Action: s3:PutObject
22
+ Condition:
23
+ ArnLike:
24
+ aws:SourceArn: !Sub "arn:${AWS::Partition}:s3:::${PolicyBucketName}"
25
+ StringEquals:
26
+ aws:SourceAccount: !Ref AWS::AccountId
27
+ Effect: Allow
28
+ Principal:
29
+ Service: logging.s3.amazonaws.com
30
+ Resource:
31
+ - !Sub "arn:${AWS::Partition}:s3:::${PolicyBucketName}/*"
32
+ Version: "2012-10-17"
human_reference_dataset/aws-cloudformation-templates/RainModules/bucket.yml ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Description: |
2
+ This module creates an S3 bucket that will pass common compliance checks
3
+ by default. It also creates an associated log bucket and replica bucket.
4
+
5
+ Parameters:
6
+
7
+ AppName:
8
+ Type: String
9
+ Description: |
10
+ This string will serve as a prefix for all resource names, which have
11
+ the general form of AppName-ResourceName-Region-Account.
12
+
13
+ Content:
14
+ Type: String
15
+ Description: A local path to a directory that will be uploaded to the bucket
16
+ Default: RAIN_NO_CONTENT
17
+
18
+ EmptyOnDelete:
19
+ Type: Boolean
20
+ Description: If true, the contents of all buckets will be permanently deleted when the stack is deleted.
21
+ Default: false
22
+
23
+ Resources:
24
+
25
+ LogBucket:
26
+ Type: AWS::S3::Bucket
27
+ Metadata:
28
+ Comment: This bucket records access logs for the main bucket
29
+ checkov:
30
+ skip:
31
+ - comment: This is the log bucket
32
+ id: CKV_AWS_18
33
+ guard:
34
+ SuppressedRules:
35
+ - S3_BUCKET_LOGGING_ENABLED
36
+ - S3_BUCKET_REPLICATION_ENABLED
37
+ Rain:
38
+ Content: RAIN_NO_CONTENT
39
+ EmptyOnDelete: !Ref EmptyOnDelete
40
+ Properties:
41
+ BucketEncryption:
42
+ ServerSideEncryptionConfiguration:
43
+ - ServerSideEncryptionByDefault:
44
+ SSEAlgorithm: AES256
45
+ BucketName: !Sub ${AppName}-logs-${AWS::Region}-${AWS::AccountId}
46
+ ObjectLockConfiguration:
47
+ ObjectLockEnabled: Enabled
48
+ Rule:
49
+ DefaultRetention:
50
+ Mode: COMPLIANCE
51
+ Years: 1
52
+ ObjectLockEnabled: true
53
+ PublicAccessBlockConfiguration:
54
+ BlockPublicAcls: true
55
+ BlockPublicPolicy: true
56
+ IgnorePublicAcls: true
57
+ RestrictPublicBuckets: true
58
+ VersioningConfiguration:
59
+ Status: Enabled
60
+
61
+ LogBucketAccess:
62
+ Type: !Rain::Module "bucket-policy.yaml"
63
+ Properties:
64
+ PolicyBucketName: !Sub ${AppName}-logs-${AWS::Region}-${AWS::AccountId}
65
+
66
+ Bucket:
67
+ Type: AWS::S3::Bucket
68
+ Metadata:
69
+ guard:
70
+ SuppressedRules:
71
+ - S3_BUCKET_DEFAULT_LOCK_ENABLED
72
+ Rain:
73
+ Content: !Ref Content
74
+ EmptyOnDelete: !Ref EmptyOnDelete
75
+ DistributionLogicalId: NONE
76
+ Properties:
77
+ BucketEncryption:
78
+ ServerSideEncryptionConfiguration:
79
+ - ServerSideEncryptionByDefault:
80
+ SSEAlgorithm: AES256
81
+ BucketName: !Sub ${AppName}-${AWS::Region}-${AWS::AccountId}
82
+ LoggingConfiguration:
83
+ DestinationBucketName: !Ref LogBucket
84
+ ObjectLockEnabled: false
85
+ PublicAccessBlockConfiguration:
86
+ BlockPublicAcls: true
87
+ BlockPublicPolicy: true
88
+ IgnorePublicAcls: true
89
+ RestrictPublicBuckets: true
90
+ ReplicationConfiguration:
91
+ Role: !GetAtt ReplicationRole.Arn
92
+ Rules:
93
+ - Destination:
94
+ Bucket: !GetAtt ReplicaBucket.Arn
95
+ Status: Enabled
96
+ VersioningConfiguration:
97
+ Status: Enabled
98
+
99
+ BucketAccess:
100
+ Type: !Rain::Module "bucket-policy.yaml"
101
+ Properties:
102
+ PolicyBucketName: !Sub ${AppName}-${AWS::Region}-${AWS::AccountId}
103
+
104
+ ReplicaBucket:
105
+ Type: AWS::S3::Bucket
106
+ Metadata:
107
+ Comment: This bucket is used as a target for replicas from the main bucket
108
+ checkov:
109
+ skip:
110
+ - comment: This is the replica bucket
111
+ id: CKV_AWS_18
112
+ guard:
113
+ SuppressedRules:
114
+ - S3_BUCKET_DEFAULT_LOCK_ENABLED
115
+ - S3_BUCKET_REPLICATION_ENABLED
116
+ - S3_BUCKET_LOGGING_ENABLED
117
+ Rain:
118
+ Content: RAIN_NO_CONTENT
119
+ EmptyOnDelete: !Ref EmptyOnDelete
120
+ Properties:
121
+ BucketEncryption:
122
+ ServerSideEncryptionConfiguration:
123
+ - ServerSideEncryptionByDefault:
124
+ SSEAlgorithm: AES256
125
+ BucketName: !Sub ${AppName}-replicas-${AWS::Region}-${AWS::AccountId}
126
+ ObjectLockEnabled: false
127
+ PublicAccessBlockConfiguration:
128
+ BlockPublicAcls: true
129
+ BlockPublicPolicy: true
130
+ IgnorePublicAcls: true
131
+ RestrictPublicBuckets: true
132
+ VersioningConfiguration:
133
+ Status: Enabled
134
+
135
+ ReplicaBucketAccess:
136
+ Type: !Rain::Module "bucket-policy.yaml"
137
+ Properties:
138
+ PolicyBucketName: !Sub ${AppName}-replicas-${AWS::Region}-${AWS::AccountId}
139
+
140
+ ReplicationPolicy:
141
+ Type: AWS::IAM::RolePolicy
142
+ Properties:
143
+ PolicyDocument:
144
+ Statement:
145
+ - Action:
146
+ - s3:GetReplicationConfiguration
147
+ - s3:ListBucket
148
+ Effect: Allow
149
+ Resource: !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}
150
+ - Action:
151
+ - s3:GetObjectVersionForReplication
152
+ - s3:GetObjectVersionAcl
153
+ - s3:GetObjectVersionTagging
154
+ Effect: Allow
155
+ Resource: !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}/*
156
+ - Action:
157
+ - s3:ReplicateObject
158
+ - s3:ReplicateDelete
159
+ - s3:ReplicationTags
160
+ Effect: Allow
161
+ Resource: !Sub arn:${AWS::Partition}:s3:::${AppName}-replicas-${AWS::Region}-${AWS::AccountId}/*
162
+ Version: "2012-10-17"
163
+ PolicyName: bucket-replication-policy
164
+ RoleName: !Ref ReplicationRole
165
+
166
+ ReplicationRole:
167
+ Type: AWS::IAM::Role
168
+ Properties:
169
+ AssumeRolePolicyDocument:
170
+ Statement:
171
+ - Action:
172
+ - sts:AssumeRole
173
+ Effect: Allow
174
+ Principal:
175
+ Service:
176
+ - s3.amazonaws.com
177
+ Version: "2012-10-17"
178
+ Path: /
179
+
180
+
human_reference_dataset/aws-cloudformation-templates/RainModules/cloudfront-nocache.yml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Parameters:
2
+
3
+ Name:
4
+ Type: String
5
+
6
+ DomainName:
7
+ Type: String
8
+
9
+ Port:
10
+ Type: String
11
+ Default: 80
12
+
13
+ Resources:
14
+
15
+ CachePolicy:
16
+ Type: AWS::CloudFront::CachePolicy
17
+ Properties:
18
+ CachePolicyConfig:
19
+ DefaultTTL: 86400
20
+ MaxTTL: 31536000
21
+ MinTTL: 1
22
+ Name: !Ref Name
23
+ ParametersInCacheKeyAndForwardedToOrigin:
24
+ CookiesConfig:
25
+ CookieBehavior: all
26
+ EnableAcceptEncodingGzip: False
27
+ HeadersConfig:
28
+ HeaderBehavior: whitelist
29
+ Headers:
30
+ - Accept-Charset
31
+ - Authorization
32
+ - Origin
33
+ - Accept
34
+ - Referer
35
+ - Host
36
+ - Accept-Language
37
+ - Accept-Encoding
38
+ - Accept-Datetime
39
+ QueryStringsConfig:
40
+ QueryStringBehavior: all
41
+
42
+ Distribution:
43
+ Type: AWS::CloudFront::Distribution
44
+ Properties:
45
+ Tags:
46
+ - Key: Name
47
+ Value: !Ref Name
48
+ - Key: Description
49
+ Value: !Ref Name
50
+ DistributionConfig:
51
+ Enabled: True
52
+ HttpVersion: http2
53
+ CacheBehaviors:
54
+ - AllowedMethods:
55
+ - GET
56
+ - HEAD
57
+ - OPTIONS
58
+ - PUT
59
+ - PATCH
60
+ - POST
61
+ - DELETE
62
+ CachePolicyId: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad
63
+ Compress: False
64
+ OriginRequestPolicyId: 216adef6-5c7f-47e4-b989-5492eafa07d3
65
+ TargetOriginId: !Sub CloudFront-${AWS::StackName}
66
+ ViewerProtocolPolicy: allow-all
67
+ PathPattern: '/proxy/*'
68
+ DefaultCacheBehavior:
69
+ AllowedMethods:
70
+ - GET
71
+ - HEAD
72
+ - OPTIONS
73
+ - PUT
74
+ - PATCH
75
+ - POST
76
+ - DELETE
77
+ CachePolicyId: !Ref CachePolicy
78
+ OriginRequestPolicyId: 216adef6-5c7f-47e4-b989-5492eafa07d3
79
+ TargetOriginId: !Sub CloudFront-${AWS::StackName}
80
+ ViewerProtocolPolicy: allow-all
81
+ Origins:
82
+ - DomainName: !Ref DomainName
83
+ Id: !Sub CloudFront-${AWS::StackName}
84
+ CustomOriginConfig:
85
+ HTTPPort: !Ref Port
86
+ OriginProtocolPolicy: http-only
human_reference_dataset/aws-cloudformation-templates/RainModules/cognito.yml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Description: This module creates a simple Cognito User Pool, Domain, and App Client.
2
+
3
+ Parameters:
4
+
5
+ AppName:
6
+ Type: String
7
+
8
+ CallbackURL:
9
+ Type: String
10
+
11
+ Resources:
12
+
13
+ UserPool:
14
+ Type: AWS::Cognito::UserPool
15
+ Properties:
16
+ UserPoolName: !Ref AppName
17
+ AdminCreateUserConfig:
18
+ AllowAdminCreateUserOnly: true
19
+ AutoVerifiedAttributes:
20
+ - email
21
+ MfaConfiguration: "OFF"
22
+ Schema:
23
+ - Name: email
24
+ Required: true
25
+ - Name: given_name
26
+ Required: true
27
+ - Name: family_name
28
+ Required: true
29
+
30
+ Domain:
31
+ Type: AWS::Cognito::UserPoolDomain
32
+ Properties:
33
+ Domain: !Ref AppName
34
+ UserPoolId: !Ref UserPool
35
+
36
+ Client:
37
+ Type: AWS::Cognito::UserPoolClient
38
+ Properties:
39
+ ClientName: !Ref AppName
40
+ GenerateSecret: false
41
+ UserPoolId: !Ref UserPool
42
+ CallbackURLs:
43
+ - !Ref CallbackURL
44
+ AllowedOAuthFlows:
45
+ - code
46
+ AllowedOAuthFlowsUserPoolClient: true
47
+ AllowedOAuthScopes:
48
+ - phone
49
+ - email
50
+ - openid
51
+ SupportedIdentityProviders:
52
+ - COGNITO
53
+
human_reference_dataset/aws-cloudformation-templates/RainModules/load-balancer.yml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Description: |
2
+ This module creates an ELBv2 load balancer
3
+
4
+ Parameters:
5
+
6
+ CertificateArn:
7
+ Type: String
8
+
9
+ VPCId:
10
+ Type: String
11
+
12
+ PublicSubnet1:
13
+ Type: String
14
+
15
+ PublicSubnet2:
16
+ Type: String
17
+
18
+ DestinationSecurityGroupId:
19
+ Type: String
20
+
21
+ Resources:
22
+
23
+ LoadBalancer:
24
+ Type: AWS::ElasticLoadBalancingV2::LoadBalancer
25
+ Metadata:
26
+ checkov:
27
+ skip:
28
+ - id: CKV_AWS_91
29
+ guard:
30
+ SuppressedRules:
31
+ - ELB_DELETION_PROTECTION_ENABLED
32
+ Properties:
33
+ LoadBalancerAttributes:
34
+ - Key: deletion_protection.enabled
35
+ Value: false
36
+ - Key: routing.http.drop_invalid_header_fields.enabled
37
+ Value: true
38
+ Scheme: internet-facing
39
+ SecurityGroups:
40
+ - Fn::GetAtt:
41
+ - LoadBalancerSecurityGroup
42
+ - GroupId
43
+ Subnets:
44
+ - !Ref PublicSubnet1
45
+ - !Ref PublicSubnet2
46
+ Type: application
47
+ # Need these... but can't put them in the module
48
+ # They will need to be overrides in the parent which is not ideal
49
+ #DependsOn:
50
+ # - PublicSubnet1DefaultRoute
51
+ # - PublicSubnet1RouteTableAssociation
52
+ # - PublicSubnet2DefaultRoute
53
+ # - PublicSubnet2RouteTableAssociation
54
+
55
+ LoadBalancerSecurityGroup:
56
+ Type: AWS::EC2::SecurityGroup
57
+ Properties:
58
+ GroupDescription: Automatically created Security Group for ELB
59
+ SecurityGroupIngress:
60
+ - CidrIp: 0.0.0.0/0
61
+ Description: Allow from anyone on port 443
62
+ FromPort: 443
63
+ IpProtocol: tcp
64
+ ToPort: 443
65
+ VpcId: !Ref VPCId
66
+
67
+ LoadBalancerEgress:
68
+ Type: AWS::EC2::SecurityGroupEgress
69
+ Properties:
70
+ Description: Load balancer to target
71
+ DestinationSecurityGroupId: !Ref DestinationSecurityGroupId
72
+ FromPort: 80
73
+ GroupId: !GetAtt LoadBalancerSecurityGroup.GroupId
74
+ IpProtocol: tcp
75
+ ToPort: 80
76
+
77
+ LoadBalancerListener:
78
+ Type: AWS::ElasticLoadBalancingV2::Listener
79
+ Metadata:
80
+ guard:
81
+ SuppressedRules:
82
+ - ELBV2_ACM_CERTIFICATE_REQUIRED
83
+ Properties:
84
+ DefaultActions:
85
+ - TargetGroupArn: !Ref TargetGroup
86
+ Type: forward
87
+ LoadBalancerArn: !Ref LoadBalancer
88
+ Port: 443
89
+ Protocol: HTTPS
90
+ Certificates:
91
+ - CertificateArn: !Ref CertificateArn
92
+ SslPolicy: ELBSecurityPolicy-TLS13-1-2-2021-06
93
+
94
+ TargetGroup:
95
+ Type: AWS::ElasticLoadBalancingV2::TargetGroup
96
+ Properties:
97
+ Port: 80
98
+ Protocol: HTTP
99
+ TargetGroupAttributes:
100
+ - Key: deregistration_delay.timeout_seconds
101
+ Value: "10"
102
+ - Key: stickiness.enabled
103
+ Value: "false"
104
+ TargetType: ip
105
+ VpcId: !Ref VPCId
106
+
107
+ Outputs:
108
+ LoadBalancerDNS:
109
+ Value: !GetAtt LoadBalancer.DNSName
110
+
human_reference_dataset/aws-cloudformation-templates/RainModules/rest-api.yml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Parameters:
2
+
3
+ AppName:
4
+ Type: String
5
+
6
+ UserPoolArn:
7
+ Type: String
8
+
9
+ Resources:
10
+
11
+ Api:
12
+ Type: AWS::ApiGateway::RestApi
13
+ Properties:
14
+ Name: !Ref AppName
15
+
16
+ ApiDeployment:
17
+ Type: AWS::ApiGateway::Deployment
18
+ Properties:
19
+ RestApiId: !Ref Api
20
+
21
+ ApiStage:
22
+ Type: AWS::ApiGateway::Stage
23
+ Properties:
24
+ RestApiId: !Ref Api
25
+ DeploymentId: !Ref ApiDeployment
26
+ StageName: prod
27
+
28
+ ApiAuthorizer:
29
+ Type: AWS::ApiGateway::Authorizer
30
+ Properties:
31
+ IdentitySource: method.request.header.authorization
32
+ Name: CognitoApiAuthorizer
33
+ ProviderARNs:
34
+ - !Ref UserPoolArn
35
+ RestApiId: !Ref Api
36
+ Type: COGNITO_USER_POOLS
37
+
human_reference_dataset/aws-cloudformation-templates/RainModules/static-site.yml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Description: This module creates a static website consisting of an S3 bucket and a CloudFront distribution.
2
+
3
+ Parameters:
4
+
5
+ AppName:
6
+ Type: String
7
+
8
+ Resources:
9
+
10
+ OriginAccessControl:
11
+ Type: AWS::CloudFront::OriginAccessControl
12
+ Properties:
13
+ OriginAccessControlConfig:
14
+ Name: !Join
15
+ - ""
16
+ - - !Ref AppName
17
+ - !Select
18
+ - 2
19
+ - !Split
20
+ - /
21
+ - !Ref AWS::StackId
22
+ OriginAccessControlOriginType: s3
23
+ SigningBehavior: always
24
+ SigningProtocol: sigv4
25
+
26
+ Distribution:
27
+ Type: AWS::CloudFront::Distribution
28
+ Metadata:
29
+ checkov:
30
+ skip:
31
+ - id: CKV_AWS_174
32
+ comment: Using the default cloudfront certificate with no aliases
33
+ guard:
34
+ SuppressedRules:
35
+ - CLOUDFRONT_CUSTOM_SSL_CERTIFICATE
36
+ - CLOUDFRONT_ORIGIN_FAILOVER_ENABLED
37
+ - CLOUDFRONT_SNI_ENABLED
38
+ Properties:
39
+ DistributionConfig:
40
+ DefaultCacheBehavior:
41
+ CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
42
+ Compress: true
43
+ TargetOriginId: !Sub ${AppName}-origin-1
44
+ ViewerProtocolPolicy: redirect-to-https
45
+ DefaultRootObject: index.html
46
+ Enabled: true
47
+ HttpVersion: http2
48
+ IPV6Enabled: true
49
+ Logging:
50
+ Bucket: !GetAtt CloudFrontLogsBucket.RegionalDomainName
51
+ Origins:
52
+ - DomainName: !GetAtt ContentBucket.RegionalDomainName
53
+ Id: !Sub ${AppName}-origin-1
54
+ OriginAccessControlId: !GetAtt OriginAccessControl.Id
55
+ S3OriginConfig:
56
+ OriginAccessIdentity: ""
57
+ ViewerCertificate:
58
+ CloudFrontDefaultCertificate: true
59
+ WebACLId: !GetAtt WebACL.Arn
60
+
61
+ WebACL:
62
+ Type: AWS::WAFv2::WebACL
63
+ Properties:
64
+ Name: WebACLWithAMR
65
+ Scope: CLOUDFRONT
66
+ Description: Web ACL with AWS Managed Rules
67
+ DefaultAction:
68
+ Allow: {}
69
+ VisibilityConfig:
70
+ SampledRequestsEnabled: true
71
+ CloudWatchMetricsEnabled: true
72
+ MetricName: MetricForWebACLWithAMR
73
+ Tags:
74
+ - Key: Name
75
+ Value: !Ref AppName
76
+ Rules:
77
+ - Name: AWS-AWSManagedRulesCommonRuleSet
78
+ Priority: 0
79
+ OverrideAction:
80
+ None: {}
81
+ VisibilityConfig:
82
+ SampledRequestsEnabled: true
83
+ CloudWatchMetricsEnabled: true
84
+ MetricName: MetricForAMRCRS
85
+ Statement:
86
+ ManagedRuleGroupStatement:
87
+ VendorName: AWS
88
+ Name: AWSManagedRulesCommonRuleSet
89
+ ExcludedRules:
90
+ - Name: NoUserAgent_HEADER
91
+
92
+ Content:
93
+ Type: !Rain::Module "bucket.yaml"
94
+ Properties:
95
+ AppName: !Sub ${AppName}-content
96
+ Overrides:
97
+ BucketAccessPolicy:
98
+ Properties:
99
+ PolicyDocument:
100
+ Statement:
101
+ - Action: s3:GetObject
102
+ Effect: Allow
103
+ Resource: !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}/*
104
+ Principal:
105
+ Service: cloudfront.amazonaws.com
106
+ Condition:
107
+ StringEquals:
108
+ AWS:SourceArn: !Sub arn:aws:cloudfront::${AWS::AccountId}:distribution/${Distribution.Id}
109
+ - Action: s3:*
110
+ Condition:
111
+ Bool:
112
+ aws:SecureTransport: false
113
+ Effect: Deny
114
+ Principal:
115
+ AWS: '*'
116
+ Resource:
117
+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}
118
+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}/*
119
+ - Action: s3:PutObject
120
+ Condition:
121
+ ArnLike:
122
+ aws:SourceArn: !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}
123
+ StringEquals:
124
+ aws:SourceAccount: !Ref AWS::AccountId
125
+ Effect: Allow
126
+ Principal:
127
+ Service: logging.s3.amazonaws.com
128
+ Resource:
129
+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-${AWS::Region}-${AWS::AccountId}/*
130
+ Version: "2012-10-17"
131
+
132
+ CloudFrontLogs:
133
+ Type: !Rain::Module "bucket.yaml"
134
+ Properties:
135
+ AppName: !Sub ${AppName}-cflogs
136
+ Overrides:
137
+ Bucket:
138
+ Properties:
139
+ OwnershipControls:
140
+ Rules:
141
+ - ObjectOwnership: BucketOwnerPreferred
142
+
human_reference_dataset/aws-cloudformation-templates/RainModules/vpc.yml ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Resources:
2
+
3
+ VPC:
4
+ Type: AWS::EC2::VPC
5
+ Properties:
6
+ CidrBlock: 10.0.0.0/16
7
+ EnableDnsHostnames: true
8
+ EnableDnsSupport: true
9
+ InstanceTenancy: default
10
+
11
+ PublicSubnet1:
12
+ Type: AWS::EC2::Subnet
13
+ Metadata:
14
+ guard:
15
+ SuppressedRules:
16
+ - SUBNET_AUTO_ASSIGN_PUBLIC_IP_DISABLED
17
+ Properties:
18
+ AvailabilityZone: !Select [0, Fn::GetAZs: !Ref "AWS::Region"]
19
+ CidrBlock: 10.0.0.0/18
20
+ MapPublicIpOnLaunch: true
21
+ VpcId: !Ref VPC
22
+
23
+ PublicSubnet1RouteTable:
24
+ Type: AWS::EC2::RouteTable
25
+ Properties:
26
+ VpcId: !Ref VPC
27
+
28
+ PublicSubnet1RouteTableAssociation:
29
+ Type: AWS::EC2::SubnetRouteTableAssociation
30
+ Properties:
31
+ RouteTableId: !Ref PublicSubnet1RouteTable
32
+ SubnetId: !Ref PublicSubnet1
33
+
34
+ PublicSubnet1DefaultRoute:
35
+ Type: AWS::EC2::Route
36
+ Metadata:
37
+ guard:
38
+ SuppressedRules:
39
+ - NO_UNRESTRICTED_ROUTE_TO_IGW
40
+ Properties:
41
+ DestinationCidrBlock: 0.0.0.0/0
42
+ GatewayId: !Ref InternetGateway
43
+ RouteTableId: !Ref PublicSubnet1RouteTable
44
+ DependsOn: VPCGW
45
+
46
+ PublicSubnet1EIP:
47
+ Type: AWS::EC2::EIP
48
+ Properties:
49
+ Domain: vpc
50
+
51
+ PublicSubnet1NATGateway:
52
+ Type: AWS::EC2::NatGateway
53
+ Properties:
54
+ AllocationId: !GetAtt PublicSubnet1EIP.AllocationId
55
+ SubnetId: !Ref PublicSubnet1
56
+ DependsOn:
57
+ - PublicSubnet1DefaultRoute
58
+ - PublicSubnet1RouteTableAssociation
59
+
60
+ PublicSubnet2:
61
+ Type: AWS::EC2::Subnet
62
+ Metadata:
63
+ guard:
64
+ SuppressedRules:
65
+ - SUBNET_AUTO_ASSIGN_PUBLIC_IP_DISABLED
66
+ Properties:
67
+ AvailabilityZone: !Select [1, Fn::GetAZs: !Ref "AWS::Region"]
68
+ CidrBlock: 10.0.64.0/18
69
+ MapPublicIpOnLaunch: true
70
+ VpcId: !Ref VPC
71
+
72
+ PublicSubnet2RouteTable:
73
+ Type: AWS::EC2::RouteTable
74
+ Properties:
75
+ VpcId: !Ref VPC
76
+
77
+ PublicSubnet2RouteTableAssociation:
78
+ Type: AWS::EC2::SubnetRouteTableAssociation
79
+ Properties:
80
+ RouteTableId: !Ref PublicSubnet2RouteTable
81
+ SubnetId: !Ref PublicSubnet2
82
+
83
+ PublicSubnet2DefaultRoute:
84
+ Type: AWS::EC2::Route
85
+ Metadata:
86
+ guard:
87
+ SuppressedRules:
88
+ - NO_UNRESTRICTED_ROUTE_TO_IGW
89
+ Properties:
90
+ DestinationCidrBlock: 0.0.0.0/0
91
+ GatewayId: !Ref InternetGateway
92
+ RouteTableId: !Ref PublicSubnet2RouteTable
93
+ DependsOn: VPCGW
94
+
95
+ PublicSubnet2EIP:
96
+ Type: AWS::EC2::EIP
97
+ Properties:
98
+ Domain: vpc
99
+
100
+ PublicSubnet2NATGateway:
101
+ Type: AWS::EC2::NatGateway
102
+ Properties:
103
+ AllocationId: !GetAtt PublicSubnet2EIP.AllocationId
104
+ SubnetId: !Ref PublicSubnet2
105
+ DependsOn:
106
+ - PublicSubnet2DefaultRoute
107
+ - PublicSubnet2RouteTableAssociation
108
+
109
+ PrivateSubnet1Subnet:
110
+ Type: AWS::EC2::Subnet
111
+ Properties:
112
+ AvailabilityZone: !Select [0, Fn::GetAZs: !Ref "AWS::Region"]
113
+ CidrBlock: 10.0.128.0/18
114
+ MapPublicIpOnLaunch: false
115
+ VpcId: !Ref VPC
116
+
117
+ PrivateSubnet1RouteTable:
118
+ Type: AWS::EC2::RouteTable
119
+ Properties:
120
+ VpcId: !Ref VPC
121
+
122
+ PrivateSubnet1RouteTableAssociation:
123
+ Type: AWS::EC2::SubnetRouteTableAssociation
124
+ Properties:
125
+ RouteTableId: !Ref PrivateSubnet1RouteTable
126
+ SubnetId: !Ref PrivateSubnet1Subnet
127
+
128
+ PrivateSubnet1DefaultRoute:
129
+ Type: AWS::EC2::Route
130
+ Properties:
131
+ DestinationCidrBlock: 0.0.0.0/0
132
+ NatGatewayId: !Ref PublicSubnet1NATGateway
133
+ RouteTableId: !Ref PrivateSubnet1RouteTable
134
+
135
+ PrivateSubnet2Subnet:
136
+ Type: AWS::EC2::Subnet
137
+ Properties:
138
+ AvailabilityZone: !Select [1, Fn::GetAZs: !Ref "AWS::Region"]
139
+ CidrBlock: 10.0.192.0/18
140
+ MapPublicIpOnLaunch: false
141
+ VpcId: !Ref VPC
142
+
143
+ PrivateSubnet2RouteTable:
144
+ Type: AWS::EC2::RouteTable
145
+ Properties:
146
+ VpcId: !Ref VPC
147
+
148
+ PrivateSubnet2RouteTableAssociation:
149
+ Type: AWS::EC2::SubnetRouteTableAssociation
150
+ Properties:
151
+ RouteTableId: !Ref PrivateSubnet2RouteTable
152
+ SubnetId: !Ref PrivateSubnet2Subnet
153
+
154
+ PrivateSubnet2DefaultRoute:
155
+ Type: AWS::EC2::Route
156
+ Properties:
157
+ DestinationCidrBlock: 0.0.0.0/0
158
+ NatGatewayId: !Ref PublicSubnet2NATGateway
159
+ RouteTableId: !Ref PrivateSubnet2RouteTable
160
+
161
+ InternetGateway:
162
+ Type: AWS::EC2::InternetGateway
163
+
164
+ VPCGW:
165
+ Type: AWS::EC2::VPCGatewayAttachment
166
+ Properties:
167
+ InternetGatewayId: !Ref InternetGateway
168
+ VpcId: !Ref VPC
169
+