You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cloud9-alpha): add support for federated-user and assumed-role for Cloud9 environment ownership (#27001)
Currently, the cloud9-alpha module only supports two IAM entities as the owners of a Cloud9 environment
- Account Root
- User
However, in many environments, access to an AWS account is gained via Federation. To use Cloud9 via the CDK in such environments, workarounds like the following one where required:
```
const cloud9 = new Ec2Environment(this, 'Cloud9', {..});
const cfnC9 = cloud9.node.findChild('Resource') as CfnEnvironmentEC2;
cfnC9.ownerArn = 'arn:sts:..;
```
This merge request adds support for assumed roles and federated users to be owners of C9 environments directly in the CDK construct.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/@aws-cdk/aws-cloud9-alpha/README.md
+43-3
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,16 @@ Every Cloud9 Environment has an **owner**. An owner has full control over the en
105
105
106
106
By default, the owner will be the identity that creates the Environment, which is most likely your CloudFormation Execution Role when the Environment is created using CloudFormation. Provider a value for the `owner` property to assign a different owner, either a specific IAM User or the AWS Account Root User.
107
107
108
-
`Owner` is a user that owns a Cloud9 environment . `Owner` has their own access permissions, resources. And we can specify an `Owner`in an Ec2 environment which could be of two types, 1. AccountRoot and 2. Iam User. It allows AWS to determine who has permissions to manage the environment, either an IAM user or the account root user (but using the account root user is not recommended, see [environment sharing best practices](https://docs.aws.amazon.com/cloud9/latest/user-guide/share-environment.html#share-environment-best-practices)).
108
+
`Owner` is an IAM entity that owns a Cloud9 environment. `Owner` has their own access permissions, and resources. You can specify an `Owner`in an EC2 environment which could be of the following types:
109
+
110
+
1. Account Root
111
+
2. IAM User
112
+
3. IAM Federated User
113
+
4. IAM Assumed Role
114
+
115
+
The ARN of the owner must satisfy the following regular expression: `^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):(iam|sts)::\d+:(root|(user\/[\w+=/:,.@-]{1,64}|federated-user\/[\w+=/:,.@-]{2,32}|assumed-role\/[\w+=:,.@-]{1,64}\/[\w+=,.@-]{1,64}))$`
116
+
117
+
Note: Using the account root user is not recommended, see [environment sharing best practices](https://docs.aws.amazon.com/cloud9/latest/user-guide/share-environment.html#share-environment-best-practices).
109
118
110
119
To specify the AWS Account Root User as the environment owner, use `Owner.accountRoot()`
111
120
@@ -114,13 +123,14 @@ declare const vpc: ec2.Vpc;
114
123
newcloud9.Ec2Environment(this, 'C9Env', {
115
124
vpc,
116
125
imageId: cloud9.ImageId.AMAZON_LINUX_2,
117
-
118
126
owner: cloud9.Owner.accountRoot('111111111')
119
127
})
120
128
```
121
129
122
130
To specify a specific IAM User as the environment owner, use `Owner.user()`. The user should have the `AWSCloud9Administrator` managed policy
123
131
132
+
The user should have the `AWSCloud9User` (preferred) or `AWSCloud9Administrator` managed policy attached.
133
+
124
134
```ts
125
135
import*asiamfrom'aws-cdk-lib/aws-iam';
126
136
@@ -135,9 +145,39 @@ new cloud9.Ec2Environment(this, 'C9Env', {
135
145
})
136
146
```
137
147
148
+
To specify a specific IAM Federated User as the environment owner, use `Owner.federatedUser(accountId, userName)`.
149
+
150
+
The user should have the `AWSCloud9User` (preferred) or `AWSCloud9Administrator` managed policy attached.
Copy file name to clipboardExpand all lines: packages/@aws-cdk/aws-cloud9-alpha/test/integ.owner.js.snapshot/OwnerIntegDefaultTestDeployAssertEE359F09.assets.json
Copy file name to clipboardExpand all lines: packages/@aws-cdk/aws-cloud9-alpha/test/integ.owner.js.snapshot/OwnerIntegDefaultTestDeployAssertEE359F09.template.json
0 commit comments