-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathpipeline.yml
100 lines (92 loc) · 2.96 KB
/
pipeline.yml
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
99
100
Parameters:
RepoOwner:
Type: String
Description: Username of the Github Repo owner
RepoName:
Type: String
Description: Name of the Github Repo
GithubCredsSecret:
Type: String
Description: Name of the AWS Secrets Manager Secret for Github creds
GithubCredsSecretParam:
Type: String
Description: Key of the Personal Access Token in the Secret
Resources:
PipelineBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Pipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Ref RepoName
ArtifactStore:
Type: S3
Location: !Ref PipelineBucket
RestartExecutionOnUpdate: true
RoleArn: !GetAtt CodePipelineRole.Arn
Stages:
- Name: Source
Actions:
- Name: GitHub
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: 1
Provider: GitHub
OutputArtifacts:
- Name: source
Configuration:
Owner: !Ref RepoOwner
Repo: !Ref RepoName
Branch: master
OAuthToken: !Sub '{{resolve:secretsmanager:${GithubCredsSecret}:SecretString:${GithubCredsSecretParam}}}'
RunOrder: 1
- Name: Update
Actions:
- Name: Pipeline
RunOrder: 1
ActionTypeId:
Category: Deploy
Owner: AWS
Version: 1
Provider: CloudFormation
InputArtifacts:
- Name: source
Configuration:
ActionMode: REPLACE_ON_FAILURE
StackName: !Ref AWS::StackName
RoleArn: !GetAtt CodePipelineRole.Arn
Capabilities: CAPABILITY_NAMED_IAM,CAPABILITY_AUTO_EXPAND
TemplatePath: source::pipeline.yml
- Name: Deploy
Actions:
- Name: Controller
RunOrder: 1
ActionTypeId:
Category: Deploy
Owner: AWS
Version: 1
Provider: CloudFormation
InputArtifacts:
- Name: source
Configuration:
ActionMode: REPLACE_ON_FAILURE
StackName: wireguard
RoleArn: !GetAtt CodePipelineRole.Arn
Capabilities: CAPABILITY_NAMED_IAM,CAPABILITY_AUTO_EXPAND
TemplatePath: source::wireguard.yml
TemplateConfiguration: !Sub source::config/wireguard-${AWS::Region}.json
CodePipelineRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- codepipeline.amazonaws.com
- cloudformation.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess