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
Copy file name to clipboardExpand all lines: README.md
+25-5Lines changed: 25 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,13 +28,27 @@
28
28
29
29
-->
30
30
31
-
Terraform module to provision a basic IAM user with permissions to access S3 resources, e.g. to give the user read/write/delete access to the objects in an S3 bucket.
31
+
Terraform module to provision a basic IAM user with permissions to access S3 resources,
32
+
e.g. to give the user read/write/delete access to the objects in an S3 bucket.
32
33
33
-
Suitable for CI/CD systems (_e.g._ TravisCI, CircleCI, CodeFresh) or systems which are *external* to AWS that cannot leverage [AWS IAM Instance Profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html).
34
+
Suitable for CI/CD systems (_e.g._ TravisCI, CircleCI) or systems which are *external* to AWS
35
+
that cannot leverage [AWS IAM Instance Profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html)
36
+
or [AWS OIDC](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html).
34
37
35
-
By default, IAM users, groups, and roles have no access to AWS resources. IAM policies are the means by which privileges are granted to users, groups, or roles. It is recommended that IAM policies be applied directly to groups and roles but not users.
38
+
By default, IAM users, groups, and roles have no access to AWS resources.
39
+
IAM policies are the means by which privileges are granted to users, groups, or roles.
40
+
It is recommended that IAM policies be applied directly to groups and roles but not users.
36
41
**This module intentionally attaches an IAM policy directly to the user and does not use groups**
37
42
43
+
The IAM user name is constructed using [terraform-null-label](https://github.com/cloudposse/terraform-null-label)
44
+
and some input is required. The simplest input is `name`. By default the name will be converted to lower case
45
+
and all non-alphanumeric characters except for hyphen will be removed. See the documentation for `terraform-null-label`
46
+
to learn how to override these defaults if desired.
47
+
48
+
If an AWS Access Key is created, it is stored either in SSM Parameter Store or is provided as a module output,
49
+
but not both. Using SSM Parameter Store is recommended because module outputs are stored in plaintext in
50
+
the Terraform state file.
51
+
38
52
---
39
53
40
54
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
| <aname="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map)| Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. |`map(string)`|`{}`| no |
167
181
| <aname="input_attributes"></a> [attributes](#input\_attributes)| ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. |`list(string)`|`[]`| no |
168
182
| <aname="input_context"></a> [context](#input\_context)| Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. |`any`| <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
183
+
| <aname="input_create_iam_access_key"></a> [create\_iam\_access\_key](#input\_create\_iam\_access\_key)| Set `true` to create an IAM Access Key for the user.<br>To rotate the key, set `false` to delete it and then back to `true` to create a new key.<br>Best practice is to never create a key and instead authenticate with OIDC or some other mechanism<br>that does not require long-lived bearer tokens. |`bool`|`true`| no |
169
184
| <aname="input_delimiter"></a> [delimiter](#input\_delimiter)| Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. |`string`|`null`| no |
170
185
| <aname="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats)| Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). |`any`|`{}`| no |
171
186
| <aname="input_enabled"></a> [enabled](#input\_enabled)| Set to false to prevent the module from creating any resources |`bool`|`null`| no |
@@ -182,6 +197,8 @@ Available targets:
182
197
| <aname="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars)| Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. |`string`|`null`| no |
183
198
| <aname="input_s3_actions"></a> [s3\_actions](#input\_s3\_actions)| Actions to allow in the policy |`list(string)`| <pre>[<br> "s3:GetObject"<br>]</pre> | no |
184
199
| <aname="input_s3_resources"></a> [s3\_resources](#input\_s3\_resources)| S3 resources to apply the actions specified in the policy |`list(string)`| n/a | yes |
200
+
| <aname="input_ssm_base_path"></a> [ssm\_base\_path](#input\_ssm\_base\_path)| The base path for SSM parameters where secrets are stored |`string`|`"/s3_user/"`| no |
201
+
| <aname="input_ssm_enabled"></a> [ssm\_enabled](#input\_ssm\_enabled)| Set `true` to store secrets in SSM Parameter Store,<br>`false` to store secrets in Terraform state as outputs.<br>Since Terraform state would contain the secrets in plaintext,<br>use of SSM Parameter Store is recommended. |`bool`|`false`| no |
185
202
| <aname="input_stage"></a> [stage](#input\_stage)| ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' |`string`|`null`| no |
186
203
| <aname="input_tags"></a> [tags](#input\_tags)| Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. |`map(string)`|`{}`| no |
187
204
| <aname="input_tenant"></a> [tenant](#input\_tenant)| ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for |`string`|`null`| no |
@@ -191,7 +208,9 @@ Available targets:
191
208
| Name | Description |
192
209
|------|-------------|
193
210
| <aname="output_access_key_id"></a> [access\_key\_id](#output\_access\_key\_id)| Access Key ID |
211
+
| <aname="output_access_key_id_ssm_path"></a> [access\_key\_id\_ssm\_path](#output\_access\_key\_id\_ssm\_path)| The SSM Path under which the S3 User's access key ID is stored |
194
212
| <aname="output_secret_access_key"></a> [secret\_access\_key](#output\_secret\_access\_key)| Secret Access Key. This will be written to the state file in plain-text |
213
+
| <aname="output_secret_access_key_ssm_path"></a> [secret\_access\_key\_ssm\_path](#output\_secret\_access\_key\_ssm\_path)| The SSM Path under which the S3 User's secret access key is stored |
195
214
| <aname="output_user_arn"></a> [user\_arn](#output\_user\_arn)| The ARN assigned by AWS for the user |
196
215
| <aname="output_user_name"></a> [user\_name](#output\_user\_name)| Normalized IAM user name |
197
216
| <aname="output_user_unique_id"></a> [user\_unique\_id](#output\_user\_unique\_id)| The user unique ID assigned by AWS |
@@ -359,7 +378,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
Terraform module to provision a basic IAM user with permissions to access S3 resources, e.g. to give the user read/write/delete access to the objects in an S3 bucket.
41
+
Terraform module to provision a basic IAM user with permissions to access S3 resources,
42
+
e.g. to give the user read/write/delete access to the objects in an S3 bucket.
42
43
43
-
Suitable for CI/CD systems (_e.g._ TravisCI, CircleCI, CodeFresh) or systems which are *external* to AWS that cannot leverage [AWS IAM Instance Profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html).
44
+
Suitable for CI/CD systems (_e.g._ TravisCI, CircleCI) or systems which are *external* to AWS
45
+
that cannot leverage [AWS IAM Instance Profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html)
46
+
or [AWS OIDC](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html).
44
47
45
-
By default, IAM users, groups, and roles have no access to AWS resources. IAM policies are the means by which privileges are granted to users, groups, or roles. It is recommended that IAM policies be applied directly to groups and roles but not users.
48
+
By default, IAM users, groups, and roles have no access to AWS resources.
49
+
IAM policies are the means by which privileges are granted to users, groups, or roles.
50
+
It is recommended that IAM policies be applied directly to groups and roles but not users.
46
51
**This module intentionally attaches an IAM policy directly to the user and does not use groups**
52
+
53
+
The IAM user name is constructed using [terraform-null-label](https://github.com/cloudposse/terraform-null-label)
54
+
and some input is required. The simplest input is `name`. By default the name will be converted to lower case
55
+
and all non-alphanumeric characters except for hyphen will be removed. See the documentation for `terraform-null-label`
56
+
to learn how to override these defaults if desired.
57
+
58
+
If an AWS Access Key is created, it is stored either in SSM Parameter Store or is provided as a module output,
59
+
but not both. Using SSM Parameter Store is recommended because module outputs are stored in plaintext in
60
+
the Terraform state file.
61
+
62
+
47
63
# How to use this project
48
64
usage: |-
49
65
This example will create an IAM user and allow read access to all objects in the S3 bucket `examplebucket`
| <aname="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map)| Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. |`map(string)`|`{}`| no |
34
34
| <aname="input_attributes"></a> [attributes](#input\_attributes)| ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. |`list(string)`|`[]`| no |
35
35
| <aname="input_context"></a> [context](#input\_context)| Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. |`any`| <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
36
+
| <aname="input_create_iam_access_key"></a> [create\_iam\_access\_key](#input\_create\_iam\_access\_key)| Set `true` to create an IAM Access Key for the user.<br>To rotate the key, set `false` to delete it and then back to `true` to create a new key.<br>Best practice is to never create a key and instead authenticate with OIDC or some other mechanism<br>that does not require long-lived bearer tokens. |`bool`|`true`| no |
36
37
| <aname="input_delimiter"></a> [delimiter](#input\_delimiter)| Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. |`string`|`null`| no |
37
38
| <aname="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats)| Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). |`any`|`{}`| no |
38
39
| <aname="input_enabled"></a> [enabled](#input\_enabled)| Set to false to prevent the module from creating any resources |`bool`|`null`| no |
@@ -49,6 +50,8 @@
49
50
| <aname="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars)| Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. |`string`|`null`| no |
50
51
| <aname="input_s3_actions"></a> [s3\_actions](#input\_s3\_actions)| Actions to allow in the policy |`list(string)`| <pre>[<br> "s3:GetObject"<br>]</pre> | no |
51
52
| <aname="input_s3_resources"></a> [s3\_resources](#input\_s3\_resources)| S3 resources to apply the actions specified in the policy |`list(string)`| n/a | yes |
53
+
| <aname="input_ssm_base_path"></a> [ssm\_base\_path](#input\_ssm\_base\_path)| The base path for SSM parameters where secrets are stored |`string`|`"/s3_user/"`| no |
54
+
| <aname="input_ssm_enabled"></a> [ssm\_enabled](#input\_ssm\_enabled)| Set `true` to store secrets in SSM Parameter Store,<br>`false` to store secrets in Terraform state as outputs.<br>Since Terraform state would contain the secrets in plaintext,<br>use of SSM Parameter Store is recommended. |`bool`|`false`| no |
52
55
| <aname="input_stage"></a> [stage](#input\_stage)| ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' |`string`|`null`| no |
53
56
| <aname="input_tags"></a> [tags](#input\_tags)| Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. |`map(string)`|`{}`| no |
54
57
| <aname="input_tenant"></a> [tenant](#input\_tenant)| ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for |`string`|`null`| no |
@@ -58,7 +61,9 @@
58
61
| Name | Description |
59
62
|------|-------------|
60
63
| <aname="output_access_key_id"></a> [access\_key\_id](#output\_access\_key\_id)| Access Key ID |
64
+
| <aname="output_access_key_id_ssm_path"></a> [access\_key\_id\_ssm\_path](#output\_access\_key\_id\_ssm\_path)| The SSM Path under which the S3 User's access key ID is stored |
61
65
| <aname="output_secret_access_key"></a> [secret\_access\_key](#output\_secret\_access\_key)| Secret Access Key. This will be written to the state file in plain-text |
66
+
| <aname="output_secret_access_key_ssm_path"></a> [secret\_access\_key\_ssm\_path](#output\_secret\_access\_key\_ssm\_path)| The SSM Path under which the S3 User's secret access key is stored |
62
67
| <aname="output_user_arn"></a> [user\_arn](#output\_user\_arn)| The ARN assigned by AWS for the user |
63
68
| <aname="output_user_name"></a> [user\_name](#output\_user\_name)| Normalized IAM user name |
64
69
| <aname="output_user_unique_id"></a> [user\_unique\_id](#output\_user\_unique\_id)| The user unique ID assigned by AWS |
0 commit comments