Skip to content

Commit 801717c

Browse files
chore(CFN): add CA & CB templated for dotnet (#689)
* feat: add dotnet build configuration --------- Co-authored-by: Jose Corella <[email protected]>
1 parent 8226fe9 commit 801717c

File tree

2 files changed

+279
-0
lines changed

2 files changed

+279
-0
lines changed

cfn/net/CA-Staging.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
AWSTemplateFormatVersion: 2010-09-09
4+
Description: "Template for CodeArtifact repositories. Creates Domain if CreateDomainFlag is True"
5+
Parameters:
6+
DomainName:
7+
Type: String
8+
Description: The name of the CodeArtifact Domain
9+
Default: crypto-tools-internal
10+
RepositoryName:
11+
Type: String
12+
Description: Base Name for the Repositories
13+
Default: dbesdk-net
14+
CreateDomainFlag:
15+
Type: String
16+
Description: Attempt to create Domain or not
17+
Default: False
18+
AllowedValues:
19+
- True
20+
- False
21+
22+
Conditions:
23+
CreateDomain: !Equals
24+
- !Ref CreateDomainFlag
25+
- True
26+
27+
Resources:
28+
Domain:
29+
Type: AWS::CodeArtifact::Domain
30+
Condition: CreateDomain
31+
Properties:
32+
DomainName: !Ref DomainName
33+
34+
StagingRepo:
35+
Type: AWS::CodeArtifact::Repository
36+
Properties:
37+
DomainName: !Ref DomainName
38+
RepositoryName: !Sub "${RepositoryName}-staging"

cfn/net/CB-Release.yml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: >-
3+
Template to build a CodeBuild Project, assumes that GitHub credentials are
4+
already set up.
5+
Parameters:
6+
ProjectName:
7+
Type: String
8+
Description: The name of the CodeBuild Project
9+
Default: AWS-DBESDK-DotNet
10+
ProjectDescription:
11+
Type: String
12+
Description: The description for the CodeBuild Project
13+
Default: CFN stack for managing CodeBuild projects for the AWS DBESDK Dotnet
14+
SourceLocation:
15+
Type: String
16+
Description: The https GitHub URL for the project
17+
Default: "https://github.com/aws/aws-database-encryption-sdk-dynamodb-java.git"
18+
NumberOfBuildsInBatch:
19+
Type: Number
20+
MaxValue: 100
21+
MinValue: 1
22+
Default: 16
23+
Description: The number of builds you expect to run in a batch
24+
Metadata:
25+
"AWS::CloudFormation::Interface":
26+
ParameterGroups:
27+
- Label:
28+
default: Crypto Tools CodeBuild Project Template
29+
Parameters:
30+
- ProjectName
31+
- ProjectDescription
32+
- SourceLocation
33+
Resources:
34+
CodeBuildProjectRelease:
35+
Type: "AWS::CodeBuild::Project"
36+
Properties:
37+
Name: !Sub "${ProjectName}-Release"
38+
Description: !Sub "CodeBuild project for ${ProjectName} to sign packages and release to Nuget."
39+
Source:
40+
Location: !Ref SourceLocation
41+
BuildSpec: codebuild/net/release/release.yml
42+
## https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html#cfn-codebuild-project-source-gitclonedepth
43+
## If this value is 0, greater than 25, or not provided then the full history is downloaded with each build project.
44+
GitCloneDepth: 0
45+
GitSubmodulesConfig:
46+
FetchSubmodules: true
47+
InsecureSsl: false
48+
ReportBuildStatus: false
49+
Type: GITHUB
50+
Artifacts:
51+
Type: NO_ARTIFACTS
52+
Cache:
53+
Type: NO_CACHE
54+
Environment:
55+
ComputeType: BUILD_GENERAL1_LARGE
56+
Image: "aws/codebuild/standard:5.0"
57+
ImagePullCredentialsType: CODEBUILD
58+
PrivilegedMode: false
59+
Type: LINUX_CONTAINER
60+
ServiceRole: !GetAtt CodeBuildServiceRoleRelease.Arn
61+
TimeoutInMinutes: 60
62+
QueuedTimeoutInMinutes: 480
63+
EncryptionKey: !Sub "arn:aws:kms:${AWS::Region}:${AWS::AccountId}:alias/aws/s3"
64+
BadgeEnabled: false
65+
BuildBatchConfig:
66+
ServiceRole: !GetAtt CodeBuildServiceRoleRelease.Arn
67+
Restrictions:
68+
MaximumBuildsAllowed: !Ref NumberOfBuildsInBatch
69+
ComputeTypesAllowed:
70+
- BUILD_GENERAL1_SMALL
71+
- BUILD_GENERAL1_MEDIUM
72+
- BUILD_GENERAL1_LARGE
73+
TimeoutInMins: 480
74+
LogsConfig:
75+
CloudWatchLogs:
76+
Status: ENABLED
77+
S3Logs:
78+
Status: DISABLED
79+
EncryptionDisabled: false
80+
81+
CodeBuildServiceRoleRelease:
82+
Type: "AWS::IAM::Role"
83+
Properties:
84+
Path: /service-role/
85+
RoleName: !Sub "codebuild-${ProjectName}-service-role-release"
86+
AssumeRolePolicyDocument: >-
87+
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"codebuild.amazonaws.com"},"Action":"sts:AssumeRole"}]}
88+
MaxSessionDuration: 3600
89+
ManagedPolicyArns:
90+
- !Ref CodeBuildBatchPolicyRelease
91+
- !Ref CodeBuildBasePolicy
92+
- !Ref AssumeArtifactRolePolicy
93+
- !Ref DbEsdkNugetAPIKeyPolicy
94+
- !Ref CodeBuildCISTSAllow
95+
- "arn:aws:iam::aws:policy/AWSCodeArtifactAdminAccess"
96+
97+
CodeBuildCISTSAllow:
98+
Type: "AWS::IAM::ManagedPolicy"
99+
Properties:
100+
ManagedPolicyName: !Sub >-
101+
CodeBuildCISTSAllow-${ProjectName}
102+
Path: /service-role/
103+
PolicyDocument: !Sub |
104+
{
105+
"Version": "2012-10-17",
106+
"Statement": [
107+
{
108+
"Effect": "Allow",
109+
"Action": "sts:AssumeRole",
110+
"Resource": "arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2"
111+
}
112+
]
113+
}
114+
115+
AssumeArtifactRolePolicy:
116+
Type: "AWS::IAM::ManagedPolicy"
117+
Properties:
118+
ManagedPolicyName: !Sub >-
119+
AssumeArtifactRolePolicy-${ProjectName}
120+
Path: /service-role/
121+
PolicyDocument: !Sub |
122+
{
123+
"Version": "2012-10-17",
124+
"Statement": [
125+
{
126+
"Effect": "Allow",
127+
"Resource": [
128+
"arn:aws:iam::395857916204:role/DbEsdkNetCodeSigning-ArtifactAccessRole"
129+
],
130+
"Action": [
131+
"sts:AssumeRole"
132+
]
133+
}
134+
]
135+
}
136+
137+
DbEsdkNugetAPIKeyPolicy:
138+
Type: "AWS::IAM::ManagedPolicy"
139+
Properties:
140+
ManagedPolicyName: !Sub >-
141+
DbEsdkNugetAPIKeyPolicy-${ProjectName}
142+
Path: /service-role/
143+
PolicyDocument: !Sub |
144+
{
145+
"Version": "2012-10-17",
146+
"Statement": [
147+
{
148+
"Effect": "Allow",
149+
"Resource": [
150+
"arn:aws:iam::582595803497:role/aws-crypto-tools-build-role"
151+
],
152+
"Action": [
153+
"sts:AssumeRole"
154+
]
155+
},
156+
{
157+
"Effect": "Allow",
158+
"Resource": [
159+
"arn:aws:secretsmanager:us-west-2:582595803497:secret:production/build/aws-crypto-tools-nuget-api-key*"
160+
],
161+
"Action": [
162+
"secretsmanager:GetSecretValue"
163+
]
164+
}
165+
]
166+
}
167+
168+
CodeBuildBatchPolicyRelease:
169+
Type: "AWS::IAM::ManagedPolicy"
170+
Properties:
171+
ManagedPolicyName: !Sub "CodeBuildBuildBatchPolicyRelease-${ProjectName}-${AWS::Region}"
172+
Path: /service-role/
173+
PolicyDocument: !Sub |
174+
{
175+
"Version": "2012-10-17",
176+
"Statement": [
177+
{
178+
"Effect": "Allow",
179+
"Resource": [
180+
"arn:aws:codebuild:${AWS::Region}:${AWS::AccountId}:project/${ProjectName}-Release"
181+
],
182+
"Action": [
183+
"codebuild:StartBuild",
184+
"codebuild:StopBuild",
185+
"codebuild:RetryBuild"
186+
]
187+
}
188+
]
189+
}
190+
191+
CodeBuildBasePolicy:
192+
Type: "AWS::IAM::ManagedPolicy"
193+
Properties:
194+
ManagedPolicyName: !Sub "CodeBuildBasePolicy-${ProjectName}-${AWS::Region}"
195+
Path: /service-role/
196+
PolicyDocument: !Sub |
197+
{
198+
"Version": "2012-10-17",
199+
"Statement": [
200+
{
201+
"Effect": "Allow",
202+
"Resource": [
203+
"arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${ProjectName}",
204+
"arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${ProjectName}:*",
205+
"arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${ProjectName}-Release",
206+
"arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${ProjectName}-Release:*"
207+
],
208+
"Action": [
209+
"logs:CreateLogGroup",
210+
"logs:CreateLogStream",
211+
"logs:PutLogEvents"
212+
]
213+
},
214+
{
215+
"Effect": "Allow",
216+
"Resource": [
217+
"arn:aws:s3:::codepipeline-${AWS::Region}-*"
218+
],
219+
"Action": [
220+
"s3:PutObject",
221+
"s3:GetObject",
222+
"s3:GetObjectVersion",
223+
"s3:GetBucketAcl",
224+
"s3:GetBucketLocation"
225+
]
226+
},
227+
{
228+
"Effect": "Allow",
229+
"Action": [
230+
"codebuild:CreateReportGroup",
231+
"codebuild:CreateReport",
232+
"codebuild:UpdateReport",
233+
"codebuild:BatchPutTestCases",
234+
"codebuild:BatchPutCodeCoverages"
235+
],
236+
"Resource": [
237+
"arn:aws:codebuild:${AWS::Region}:${AWS::AccountId}:report-group/${ProjectName}-*"
238+
]
239+
}
240+
]
241+
}

0 commit comments

Comments
 (0)