forked from aws/aws-toolkit-azure-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_cfn.yaml
68 lines (66 loc) · 2.3 KB
/
example_cfn.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
AWSTemplateFormatVersion: "2010-09-09"
Description: |
"Create IAM OIDC provider and IAM Role for Azure DevOps Service Connection.
This template is for illustrative purposes only."
Parameters:
AzdoOrgId:
Type: String
Default: "00000000-0000-0000-0000-000000000000"
Description: |
"ID of your Azure DevOps Organization.
This can be obtained by downloading a list of projects connected to your Azure DevOps Organization.
The exported list of Projects will contain the Organization ID."
AzdoOrgName:
Type: String
Default: "example-devops-org"
Description: "Name of your Azure DevOps Organization."
AzdoProjectName:
Type: String
Default: "example-devops-project"
Description: "Name of your Azure DevOps Project."
AzdoScnName:
Type: String
Default: "example-aws-service-connection"
Description: "Name of your Azure DevOps Service Connection"
AzdoServiceConnectionRoleName:
Type: String
Default: "example-azure-devops-role"
Description: |
"Name of the IAM Role.
This must match the 'Role to Assume' property of the Service Connection."
Resources:
OidcIdp:
Type: AWS::IAM::OIDCProvider
Properties:
ClientIdList:
- api://AzureADTokenExchange
Url: !Sub "https://vstoken.dev.azure.com/${AzdoOrgId}"
ScnRole:
Type: "AWS::IAM::Role"
Properties:
Path: "/"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess
RoleName: !Ref AzdoServiceConnectionRoleName
AssumeRolePolicyDocument: !Sub |
{
"Version": "2012-10-17",
"Statement": [
{
"Condition": {
"StringEquals": {
"vstoken.dev.azure.com/${AzdoOrgId}:aud": "api://AzureADTokenExchange",
"vstoken.dev.azure.com/${AzdoOrgId}:sub": "sc://${AzdoOrgName}/${AzdoProjectName}/${AzdoScnName}"
}
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::${AWS::AccountId}:oidc-provider/vstoken.dev.azure.com/${AzdoOrgId}"
}
}
]
}
Outputs:
ScnRoleArn:
Value: !GetAtt ScnRole.Arn