Skip to content

Commit 078521d

Browse files
Added section to AWS Account page for configuring OIDC session tags (#2792)
Co-authored-by: Steve Fenton <[email protected]>
1 parent 6c3ae05 commit 078521d

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed
658 KB
Loading
388 KB
Loading

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

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: src/layouts/Default.astro
33
pubDate: 2023-01-01
4-
modDate: 2023-01-01
4+
modDate: 2025-08-18
55
title: AWS accounts
66
description: Configure your infrastructure so Octopus can deploy infrastructure to AWS and run scripts against the AWS CLI.
77
navOrder: 20
@@ -111,6 +111,83 @@ For example, to lock an identity role to any Octopus environment, you can update
111111
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.
112112
:::
113113

114+
#### Passing Session Tags
115+
116+
AWS Accounts can be configured to pass [session tags](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_adding-assume-role-idp) when assuming the AWS IAM role. This can be a useful tactic to allow using a single Octopus AWS Account and AWS IAM Role across many projects or environments, reducing configuration sprawl.
117+
118+
To pass session tags, use the `Custom Claims` field on the AWS OIDC Account.
119+
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).
121+
122+
The example below demonstrates supplying a session tag with a key of `octopus-project` and a value of the project name.
123+
```json
124+
125+
{
126+
"principal_tags": {
127+
"octopus-project": ["#{Octopus.Project.Name}"]
128+
},
129+
"transitive_tag_keys": [
130+
"octopus-project"
131+
]
132+
}
133+
```
134+
135+
![AWS OIDC Custom Claim](./aws-oidc-custom-claim.png)
136+
137+
You will need to [allow the sts:TagSession action](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required) in the Trust relationships policy for the AWS role. For example:
138+
139+
```json
140+
{
141+
"Version": "2012-10-17",
142+
"Statement": [
143+
{
144+
"Effect": "Allow",
145+
"Principal": {
146+
"Federated": "arn:aws:iam::133577414924:oidc-provider/acme.octopus.app"
147+
},
148+
"Action": [
149+
"sts:AssumeRoleWithWebIdentity",
150+
"sts:TagSession"],
151+
"Condition": {
152+
"StringEquals": {
153+
"acme.octopus.app:aud": "acme.octopus.app"
154+
}
155+
}
156+
}
157+
]
158+
}
159+
160+
```
161+
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).
163+
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.
165+
166+
```json
167+
{
168+
"Version": "2012-10-17",
169+
"Statement": [
170+
{
171+
"Effect": "Allow",
172+
"Action": [
173+
"ec2:StartInstances",
174+
"ec2:StopInstances"
175+
],
176+
"Resource": "arn:aws:ec2:*:*:instance/*",
177+
"Condition": {
178+
"StringEquals": {"aws:ResourceTag/octopus-project": "${aws:PrincipalTag/octopus-project}"}
179+
}
180+
},
181+
{
182+
"Effect": "Allow",
183+
"Action": "ec2:DescribeInstances",
184+
"Resource": "*"
185+
}
186+
]
187+
}
188+
```
189+
![AWS IAM Policy](./aws-iam-ec2-start-stop-policy.png)
190+
114191
## AWS account variables
115192

116193
You can access your AWS account from within projects through a variable of type **AWS Account Variable**. Learn more about [AWS Account Variables](/docs/projects/variables/aws-account-variables)

0 commit comments

Comments
 (0)