Skip to content

Commit 11b1a88

Browse files
bpmctkylecarbs
authored andcommitted
example: ec2: document "minimal" policy (#1536)
* example: ec2: document "minimal" policy * move DescribeInstances * move ModifyInstanceCreditSpecification
1 parent 2a8a8ba commit 11b1a88

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

examples/aws-linux/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,62 @@ name: Develop in Linux on AWS EC2
33
description: Get started with Linux development on AWS EC2.
44
tags: [cloud, aws]
55
---
6+
7+
# aws-linux
8+
9+
## Getting started
10+
11+
Pick this template in `coder templates init` and follow instructions.
12+
13+
## Required permissions / policy
14+
15+
This example policy allows Coder to create EC2 instances and modify instances provisioned by Coder.
16+
17+
```json
18+
{
19+
"Version": "2012-10-17",
20+
"Statement": [
21+
{
22+
"Sid": "VisualEditor0",
23+
"Effect": "Allow",
24+
"Action": [
25+
"ec2:GetDefaultCreditSpecification",
26+
"ec2:DescribeIamInstanceProfileAssociations",
27+
"ec2:DescribeTags",
28+
"ec2:CreateTags",
29+
"ec2:RunInstances",
30+
"ec2:DescribeInstanceCreditSpecifications",
31+
"ec2:DescribeImages",
32+
"ec2:ModifyDefaultCreditSpecification",
33+
"ec2:DescribeVolumes"
34+
],
35+
"Resource": "*"
36+
},
37+
{
38+
"Sid": "CoderResouces",
39+
"Effect": "Allow",
40+
"Action": [
41+
"ec2:DescribeInstances",
42+
"ec2:DescribeInstanceAttribute",
43+
"ec2:UnmonitorInstances",
44+
"ec2:TerminateInstances",
45+
"ec2:StartInstances",
46+
"ec2:StopInstances",
47+
"ec2:DeleteTags",
48+
"ec2:MonitorInstances",
49+
"ec2:CreateTags",
50+
"ec2:RunInstances",
51+
"ec2:ModifyInstanceAttribute",
52+
"ec2:ModifyInstanceCreditSpecification"
53+
],
54+
"Resource": "arn:aws:ec2:*:*:instance/*",
55+
"Condition": {
56+
"StringEquals": {
57+
"aws:ResourceTag/Coder_Provisioned": "true"
58+
}
59+
}
60+
}
61+
]
62+
}
63+
```
64+

examples/aws-linux/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ variable "access_key" {
1111
description = <<EOT
1212
Create an AWS access key to provision resources with Coder:
1313
- https://console.aws.amazon.com/iam/home#/users
14+
15+
See the template README for an example permissions policy,
16+
if needed.
1417
1518
AWS Access Key ID
1619
EOT
@@ -138,5 +141,7 @@ resource "aws_instance" "dev" {
138141
user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end
139142
tags = {
140143
Name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
144+
# Required if you are using our example policy, see template README
145+
Coder_Provisioned = "true"
141146
}
142147
}

0 commit comments

Comments
 (0)