Skip to content

Commit 9b1e620

Browse files
authored
Remove rogue colon from example IAM policies (#3077)
* Remove rogue colon from example IAM policies * markdown linting fixes - visual checks done in local dev env
1 parent b0d656b commit 9b1e620

1 file changed

Lines changed: 47 additions & 40 deletions

File tree

  • src/pages/docs/infrastructure/accounts/aws

src/pages/docs/infrastructure/accounts/aws/index.md

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,64 +48,67 @@ When setting up the identity provider you need to use the host domain name of yo
4848
#### Configuring AWS OIDC Account
4949

5050
1. Navigate to **Deploy ➜ Manage ➜ Accounts**, click the **ADD ACCOUNT** and select **AWS Account**.
51-
2. Add a memorable name for the account.
52-
3. Provide a description for the account.
53-
4. Set the **Role ARN** to the ARN from the identity provider associated role. Note that this is different to the ARN of your Identity Provider.
54-
5. Set the **Session Duration** to the Maximum session duration from the role, in seconds.
55-
6. Click **SAVE** to save the account.
56-
7. Before you can test the account you need to add a condition to the identity provider in AWS under **IAM ➜ Roles ➜ {Your AWS Role} ➜ Trust Relationship** :
57-
```json
58-
{
59-
"Version": "2012-10-17",
60-
"Statement": [
51+
1. Add a memorable name for the account.
52+
1. Provide a description for the account.
53+
1. Set the **Role ARN** to the ARN from the identity provider associated role. Note that this is different to the ARN of your Identity Provider.
54+
1. Set the **Session Duration** to the Maximum session duration from the role, in seconds.
55+
1. Click **SAVE** to save the account.
56+
1. Before you can test the account you need to add a condition to the identity provider in AWS under **IAM ➜ Roles ➜ {Your AWS Role} ➜ Trust Relationship** :
57+
58+
```json
6159
{
62-
"Effect": "Allow",
63-
"Principal": {
64-
"Federated": "arn:aws:iam::{aws-account}:oidc-provider/{your-identity-provider}"
65-
},
66-
"Action": "sts:AssumeRoleWithWebIdentity",
67-
"Condition": {
68-
"StringEquals": {
69-
"example.octopus.app:sub": "space:[space-slug]:account:[slug-of-account-created-above]",
70-
"example.octopus.app:aud": "example.octopus.app"
60+
"Version": "2012-10-17",
61+
"Statement": [
62+
{
63+
"Effect": "Allow",
64+
"Principal": {
65+
"Federated": "arn:aws:iam::{aws-account}:oidc-provider/{your-identity-provider}"
66+
},
67+
"Action": "sts:AssumeRoleWithWebIdentity",
68+
"Condition": {
69+
"StringEquals": {
70+
"example.octopus.app:sub": "space:[space-slug]:account:[slug-of-account-created-above]",
71+
"example.octopus.app:aud": "example.octopus.app"
72+
}
73+
}
7174
}
72-
}
75+
]
7376
}
74-
]
75-
}
76-
```
77-
8. Go back to the AWS account in Octopus and click **SAVE AND TEST** to verify the credentials are valid.
77+
```
78+
79+
1. Go back to the AWS account in Octopus and click **SAVE AND TEST** to verify the credentials are valid.
7880

7981
Please read [OpenID Connect Subject Identifier](/docs/infrastructure/accounts/openid-connect#subject-keys) on how to customize the **Subject** value.
8082

81-
By default, the role trust policy does not have any conditions on the subject identifier. To lock the role down to particular usages you need to modify the [trust policy conditions](https://oc.to/aws-iam-policy-conditions) and add a condition for the `sub`.
83+
By default, the role trust policy does not have any conditions on the subject identifier. To lock the role down to particular usages you need to modify the [trust policy conditions](https://oc.to/aws-iam-policy-conditions) and add a condition for the `sub`.
8284

8385
For example, to lock an identity role to a specific Octopus environment, you can update the conditions:
8486

8587
```json
8688
"Condition": {
8789
"StringEquals": {
8890
"example.octopus.app:sub": "space:default:project:aws-oidc-testing:environment:dev",
89-
"example.octopus.app:aud": "example.octopus.app:"
91+
"example.octopus.app:aud": "example.octopus.app"
9092
}
9193
}
9294
```
9395

94-
`default`, `aws-oidc-testing` and `dev` are the slugs of their respective Octopus resources.
96+
`default`, `aws-oidc-testing` and `dev` are the slugs of their respective Octopus resources.
9597

96-
AWS policy conditions also support complex matching with wildcards and `StringLike` expressions.
98+
AWS policy conditions also support complex matching with wildcards and `StringLike` expressions.
9799

98100
For example, to lock an identity role to any Octopus environment, you can update the conditions:
99101

100102
```json
101103
"Condition": {
102104
"StringLike": {
103105
"example.octopus.app:sub": "space:default:project:aws-oidc-testing:environment:*",
104-
"example.octopus.app:aud": "example.octopus.app:"
106+
"example.octopus.app:aud": "example.octopus.app"
105107
}
106108
}
107109
```
108-
`default` and `aws-oidc-testing` are the slugs of their respective Octopus resources.
110+
111+
`default` and `aws-oidc-testing` are the slugs of their respective Octopus resources.
109112

110113
:::div{.hint}
111114
AWS steps can also defer to the IAM role assigned to the instance that hosts the Octopus Server for authentication. In this scenario there is no need to create the AWS account.
@@ -117,9 +120,10 @@ AWS Accounts can be configured to pass [session tags](https://docs.aws.amazon.co
117120

118121
To pass session tags, use the `Custom Claims` field on the AWS OIDC Account.
119122

120-
The Claim should be `https://aws.amazon.com/tags`, and the Value should be a JSON object with a `principal_tags` property as documented in the [AWS docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_adding-assume-role-idp).
123+
The Claim should be `https://aws.amazon.com/tags`, and the Value should be a JSON object with a `principal_tags` property as documented in the [AWS docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_adding-assume-role-idp).
121124

122125
The example below demonstrates supplying a session tag with a key of `octopus-project` and a value of the project name.
126+
123127
```json
124128

125129
{
@@ -159,9 +163,9 @@ You will need to [allow the sts:TagSession action](https://docs.aws.amazon.com/I
159163

160164
```
161165

162-
These session tags can then be used to control access to AWS resources by [tagging the AWS resources](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html#access_tags_control-resources).
166+
These session tags can then be used to control access to AWS resources by [tagging the AWS resources](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html#access_tags_control-resources).
163167

164-
For example, the policy below allows starting and stopping EC2 instances which are tagged with a key of `octopus-project` and a value matching the project supplied in the session tags supplied as shown above.
168+
For example, the policy below allows starting and stopping EC2 instances which are tagged with a key of `octopus-project` and a value matching the project supplied in the session tags supplied as shown above.
165169

166170
```json
167171
{
@@ -186,6 +190,7 @@ For example, the policy below allows starting and stopping EC2 instances which a
186190
]
187191
}
188192
```
193+
189194
![AWS IAM Policy](./aws-iam-ec2-start-stop-policy.png)
190195

191196
## AWS account variables
@@ -214,7 +219,7 @@ The first login process attempts to inherit the role from a web identity token.
214219
When the `Execute using the AWS service role for an EC2 instance` option is enabled, a worker will first attempt to inherit a pod web identity.
215220
:::
216221

217-
The second login process queries the [Instance Metadata Service](https://oc.to/InstanceMetadataAndUserData) (IMDS), made available to EC2 instances. IMDS is exposed as an HTTP API accessed via http://169.254.169.254. The keys required to assume a service role associated with an EC2 instance are generated by calling the IMDS HTTP API.
222+
The second login process queries the [Instance Metadata Service](https://oc.to/InstanceMetadataAndUserData) (IMDS), made available to EC2 instances. IMDS is exposed as an HTTP API accessed via `http://169.254.169.254`. The keys required to assume a service role associated with an EC2 instance are generated by calling the IMDS HTTP API.
218223

219224
IMDS has two versions, v1, and v2. [IMDSv2 is available to all EC2 instances](https://oc.to/UseIMDSv2) and is optionally required over IMDSv1. Octopus uses IMDSv2 to inherit IAM roles. The worker assumes that IAM role if the request to generate account tokens from the IMDSv2 HTTP API succeeds.
220225

@@ -233,20 +238,22 @@ First, add the AWS Account as a variable. In the screenshot below, the account h
233238
The **OctopusPrintVariables** has been set to true to print the variables to the output logs. This is a handy way to view the available variables that can be consumed by a custom script. You can find more information on debugging variables at [Debug problems with Octopus variables](/docs/support/debug-problems-with-octopus-variables).
234239

235240
:::figure
236-
![](/docs/img/infrastructure/accounts/aws/variables.png)
241+
![A project variables screen showing two variables. The first, OctopusPrintVariables, has a value of 'True'. The second, AWS Account, has a value with AWS Account type](/docs/img/infrastructure/accounts/aws/variables.png)
237242
:::
238243

239244
When running a step, the available variables will be printed to the log. In this example, the following variables are shown:
240245

241-
**Access Key Account**
242-
```
246+
For a Access Key Account:
247+
248+
```txt
243249
[AWS Account] = 'amazon-web-services-account'
244250
[AWS Account.AccessKey] = 'YOUR_ACCESS_KEY'
245251
[AWS Account.SecretKey] = '********'
246252
```
247253

248-
**OpenID Connect Account**
249-
```
254+
For a OpenID Connect Account:
255+
256+
```txt
250257
[AWS Account] = 'amazon-web-services-account'
251258
[AWS Account.RoleArn] = 'arn:aws:iam::123456789012:role/test-role'
252259
[AWS Account.SessionDuration] = '3600'
@@ -257,7 +264,7 @@ When running a step, the available variables will be printed to the log. In this
257264

258265
You can then use these variables in your scripts or other step types. For example, the following PowerShell script would print the access key to the console.
259266

260-
```
267+
```powershell
261268
Write-Host "$($OctopusParameters["AWS Account.AccessKey"])"
262269
```
263270

0 commit comments

Comments
 (0)