Skip to content

Commit 7e0e79d

Browse files
authored
Update Documentation for OIDC Setup (#567)
1 parent 05d17fd commit 7e0e79d

File tree

2 files changed

+75
-6
lines changed

2 files changed

+75
-6
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ The [User Guide](https://docs.aws.amazon.com/vsts/latest/userguide/welcome.html)
3030

3131
## Credentials Handling for AWS Services
3232

33-
To enable tasks to call AWS services when run as part of your build or release pipelines AWS credentials need to have been configured for the tasks or be available in the host process for the build agent. Note that the credentials are used specifically by the tasks when run in a build agent process, they are not related to end-user logins to your Azure DevOps instance.
33+
To enable tasks to call AWS services when run as part of your build or release pipelines, AWS credentials need to have been configured for the tasks or be available in the host process for the build agent. Note that the credentials are used specifically by the tasks when run in a build agent process, they are not related to end-user logins to your Azure DevOps instance.
3434

3535
The AWS tasks support the following mechanisms for obtaining AWS credentials:
3636

3737
One or more service endpoints, of type _AWS_, can be created and populated with either:
3838

3939
- Static credentials in the form of AWS access and secret keys, and optionally data for _Assumed Role_ credentials.
40-
- If only the _Assumed Role_ is defined but neither access key ID nor secret key, the role be assumed regardless. This is useful when using instance profices, and and profile only allows to assume a role.
41-
- If the useOIDC is checked and you have defined an _Assumed Role_ without access key ID or secret key. This will request an OIDC token from Azure Devops and federate into AWS with than token.
40+
- If only the _Assumed Role_ is defined but neither access key ID nor secret key, the role will be assumed regardless. This is useful when using instance profiles, and profile which only allows to assume a role.
41+
- If `Use OIDC` is checked and you have defined an _Assumed Role_ without an access key ID or secret key, an OIDC token will be requested from Azure Devops and used to federate into AWS.
4242

43-
- This will require a trust policy on the _Assume Role_ similar to this :
43+
- Using OIDC requires the creation of an OIDC Provider. Please refer to the documentation here: [Creating and managing an OIDC provider](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html#manage-oidc-provider-console)
44+
- This will also require a trust policy on the _Assume Role_ similar to this :
4445

4546
```json
4647
{
@@ -54,7 +55,7 @@ One or more service endpoints, of type _AWS_, can be created and populated with
5455
"Action": "sts:AssumeRoleWithWebIdentity",
5556
"Condition": {
5657
"StringEquals": {
57-
"vstoken.dev.azure.com/{org-id}:sub": "sc://{orgName}/{ProjectName}/{ServiceConnections}",
58+
"vstoken.dev.azure.com/{org-id}:sub": "sc://{orgName}/{ProjectName}/{ServiceConnectionName}",
5859
"vstoken.dev.azure.com/{org-id}:aud": "api://AzureADTokenExchange"
5960
}
6061
}
@@ -63,7 +64,7 @@ One or more service endpoints, of type _AWS_, can be created and populated with
6364
}
6465
```
6566

66-
You'll also have to setup the OIDC Provider, you can use the documentation of [Creating and managing an OIDC provider](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html#manage-oidc-provider-console)
67+
- A sample CloudFormation template [example_cfn.yml](./example_cfn.yaml) is available to assist with the setup and configuration.
6768

6869
- Variables defined on the task or build.
6970
- If tasks are not configured with the name of a service endpoint they will attempt to obtain credentials, and optionally region, from variables defined in the build environment. The

example_cfn.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
3+
Description: |
4+
"Create IAM OIDC provider and IAM Role for Azure DevOps Service Connection.
5+
This template is for illustrative purposes only."
6+
7+
Parameters:
8+
AzdoOrgId:
9+
Type: String
10+
Default: "00000000-0000-0000-0000-000000000000"
11+
Description: |
12+
"ID of your Azure DevOps Organization.
13+
This can be obtained by downloading a list of projects connected to your Azure DevOps Organization.
14+
The exported list of Projects will contain the Organization ID."
15+
AzdoOrgName:
16+
Type: String
17+
Default: "example-devops-org"
18+
Description: "Name of your Azure DevOps Organization."
19+
AzdoProjectName:
20+
Type: String
21+
Default: "example-devops-project"
22+
Description: "Name of your Azure DevOps Project."
23+
AzdoScnName:
24+
Type: String
25+
Default: "example-aws-service-connection"
26+
Description: "Name of your Azure DevOps Service Connection"
27+
AzdoServiceConnectionRoleName:
28+
Type: String
29+
Default: "example-azure-devops-role"
30+
Description: |
31+
"Name of the IAM Role.
32+
This must match the 'Role to Assume' property of the Service Connection."
33+
Resources:
34+
OidcIdp:
35+
Type: AWS::IAM::OIDCProvider
36+
Properties:
37+
ClientIdList:
38+
- api://AzureADTokenExchange
39+
Url: !Sub "https://vstoken.dev.azure.com/${AzdoOrgId}"
40+
ScnRole:
41+
Type: "AWS::IAM::Role"
42+
Properties:
43+
Path: "/"
44+
ManagedPolicyArns:
45+
- arn:aws:iam::aws:policy/AdministratorAccess
46+
RoleName: !Ref AzdoServiceConnectionRoleName
47+
AssumeRolePolicyDocument: !Sub |
48+
{
49+
"Version": "2012-10-17",
50+
"Statement": [
51+
{
52+
"Condition": {
53+
"StringEquals": {
54+
"vstoken.dev.azure.com/${AzdoOrgId}:aud": "api://AzureADTokenExchange",
55+
"vstoken.dev.azure.com/${AzdoOrgId}:sub": "sc://${AzdoOrgName}/${AzdoProjectName}/${AzdoScnName}"
56+
}
57+
},
58+
"Action": "sts:AssumeRoleWithWebIdentity",
59+
"Effect": "Allow",
60+
"Principal": {
61+
"Federated": "arn:aws:iam::${AWS::AccountId}:oidc-provider/vstoken.dev.azure.com/${AzdoOrgId}"
62+
}
63+
}
64+
]
65+
}
66+
Outputs:
67+
ScnRoleArn:
68+
Value: !GetAtt ScnRole.Arn

0 commit comments

Comments
 (0)