Skip to content

Commit fa3082b

Browse files
committed
Creating Cross-Account Secrets pipelines
1 parent 18318e7 commit fa3082b

File tree

2 files changed

+110
-3
lines changed

2 files changed

+110
-3
lines changed

cicd/cloudformation/release.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,19 @@ Resources:
820820
Resource:
821821
- !Sub ${ArtifactBucket.Arn}/*
822822
- !Sub ${AppBucket.Arn}/*
823+
- Action: 'serverlessrepo:*'
824+
Effect: Allow
825+
Resource:
826+
- !Sub arn:aws:serverlessrepo:${AWS::Region}:${AWS::AccountId}:applications/*
827+
- Action:
828+
- 'ssm:GetParameters'
829+
- 'ssm:PutParameter'
830+
- 'ssm:DeleteParameter'
831+
- 'ssm:DeleteParameters'
832+
- 'ssm:DescribeParameters'
833+
Effect: Allow
834+
Resource:
835+
- !Sub arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/SSOSync/*
823836

824837
CodeBuildPublishRole:
825838
Type: AWS::IAM::Role

cicd/cloudformation/testing.yaml

+97-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Resources:
141141
StringEquals:
142142
aws:SourceAccount: !Ref AWS::AccountId
143143

144-
CodePipeline:
144+
CodePipelineTestAccountExecution:
145145
Type: AWS::CodePipeline::Pipeline
146146
Properties:
147147
Name: SSOSync-Test-Account_Execution
@@ -249,6 +249,100 @@ Resources:
249249
- Name: Tests
250250
RunOrder: 1
251251

252+
CodePipelineDeployCrossAccountSecrets:
253+
Type: AWS::CodePipeline::Pipeline
254+
Condition: DeployManagement
255+
Properties:
256+
Name: SSOSync-Deploy_CrossAccount_Secrets
257+
RoleArn: !Sub ${CodePipelineRole.Arn}
258+
ArtifactStore:
259+
Type: S3
260+
Location: !Ref ArtifactBucket
261+
EncryptionKey:
262+
Type: KMS
263+
Id: !GetAtt ArtifactBucketKey.Arn
264+
Stages:
265+
- Name: Source
266+
Actions:
267+
- Name: Tests
268+
Namespace: Test
269+
ActionTypeId:
270+
Category: Source
271+
Owner: AWS
272+
Version: 1
273+
Provider: S3
274+
OutputArtifacts:
275+
- Name: Tests
276+
RunOrder: '1'
277+
Configuration:
278+
S3Bucket: !Ref StagingBucket
279+
S3ObjectKey: tests.zip
280+
PollForSourceChanges: false
281+
- Name: Deploy
282+
Actions:
283+
- Name: Deploy
284+
ActionTypeId:
285+
Category: Deploy
286+
Owner: AWS
287+
Version: '1'
288+
Provider: CloudFormation
289+
Configuration:
290+
ActionMode: CREATE_UPDATE
291+
Capabilities: CAPABILITY_IAM,CAPABILITY_AUTO_EXPAND,CAPABILITY_NAMED_IAM
292+
StackName: SmokeTest
293+
RoleArn: !GetAtt [CloudFormationDeployerRole, Arn]
294+
TemplateConfiguration: 'Tests::deploy/cross_account_secrets.json'
295+
TemplatePath: !Sub 'Tests::deploy/cross_account_secrets..yml'
296+
InputArtifacts:
297+
- Name: Tests
298+
RunOrder: 1
299+
300+
CodePipelineCleanUpCrossAccountSecrets:
301+
Type: AWS::CodePipeline::Pipeline
302+
Condition: DeployManagement
303+
Properties:
304+
Name: SSOSync-CleanUp_CrossAccount_Secrets
305+
RoleArn: !Sub ${CodePipelineRole.Arn}
306+
ArtifactStore:
307+
Type: S3
308+
Location: !Ref ArtifactBucket
309+
EncryptionKey:
310+
Type: KMS
311+
Id: !GetAtt ArtifactBucketKey.Arn
312+
Stages:
313+
- Name: Source
314+
Actions:
315+
- Name: Tests
316+
Namespace: Test
317+
ActionTypeId:
318+
Category: Source
319+
Owner: AWS
320+
Version: 1
321+
Provider: S3
322+
OutputArtifacts:
323+
- Name: Tests
324+
RunOrder: '1'
325+
Configuration:
326+
S3Bucket: !Ref StagingBucket
327+
S3ObjectKey: tests.zip
328+
PollForSourceChanges: false
329+
- Name: CleanUp
330+
Actions:
331+
- Name: RemoveStack
332+
ActionTypeId:
333+
Category: Deploy
334+
Owner: AWS
335+
Version: 1
336+
Provider: CloudFormation
337+
Configuration:
338+
ActionMode: DELETE_ONLY
339+
StackName: SmokeTest
340+
RoleArn: !GetAtt [CloudFormationDeployerRole, Arn]
341+
InputArtifacts:
342+
- Name: Tests
343+
RunOrder: 1
344+
345+
252346

253347
CodeBuildSmokeCLI:
254348
Type: AWS::CodeBuild::Project
@@ -258,7 +352,7 @@ Resources:
258352
ServiceRole: !Ref CodeBuildTestRole
259353
Source:
260354
Type: CODEPIPELINE
261-
BuildSpec: "tests/deploy_patterns/cli/buildspec.yml"
355+
BuildSpec: "tests/account_execution/cli/buildspec.yml"
262356
Environment:
263357
ComputeType: BUILD_GENERAL1_SMALL
264358
Image: aws/codebuild/standard:5.0
@@ -289,7 +383,7 @@ Resources:
289383
ServiceRole: !Ref CodeBuildTestRole
290384
Source:
291385
Type: CODEPIPELINE
292-
BuildSpec: "tests/deploy_patterns/lambda/buildspec.yml"
386+
BuildSpec: "tests/account_execution/lambda/buildspec.yml"
293387
Environment:
294388
ComputeType: BUILD_GENERAL1_SMALL
295389
Image: aws/codebuild/standard:5.0

0 commit comments

Comments
 (0)