Module: iam-system-user
Terraform Module to provision a basic IAM system user suitable for CI/CD Systems (e.g. TravisCI, CircleCI) or systems which are external to AWS that cannot leverage AWS IAM Instance Profiles or AWS OIDC.
We do not recommend creating IAM users this way for any other purpose.
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. This module intentionally attaches an IAM policy directly to the user and does not use groups
The IAM user name is constructed using terraform-null-label
and some input is required. The simplest input is name
. By default the name will be converted to lower case
and all non-alphanumeric characters except for hyphen will be removed. See the documentation for terraform-null-label
to learn how to override these defaults if desired.
If an AWS Access Key is created, it is stored either in SSM Parameter Store or is provided as a module output, but not both. Using SSM Parameter Store is recommended because module outputs are stored in plaintext in the Terraform state file.
Usage
module "circleci" {
source = "cloudposse/iam-system-user/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "circleci"
name = "assets"
}
Examples
module "fluentd_user" {
source = "cloudposse/iam-system-user/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "dev"
name = "fluentd"
policy_arns_map = {
logs = "arn:aws:iam::aws:policy/CloudWatchLogsFullAccess"
}
inline_policies_map = {
s3 = data.aws_iam_policy_document.s3_policy.json
}
}
data "aws_iam_policy_document" "s3_policy" {
statement {
actions = [
"s3:PutObject",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObjectAcl"
]
resources = [
"arn:aws:s3:::bucket_name/*",
"arn:aws:s3:::bucket_name/"
]
}
}
Variables
Required Variables
Optional Variables
create_iam_access_key
(bool
) optionalWhether or not to create IAM access keys
Default value:
true
force_destroy
(bool
) optionalDestroy the user even if it has non-Terraform-managed IAM access keys, login profile or MFA devices
Default value:
false
inline_policies
(list(string)
) optionalInline policies to attach to our created user
Default value:
[ ]
inline_policies_map
(map(string)
) optionalInline policies to attach (descriptive key => policy)
Default value:
{ }
path
(string
) optionalPath in which to create the user
Default value:
"/"
permissions_boundary
(string
) optionalPermissions Boundary ARN to attach to our created user
Default value:
null
policy_arns
(list(string)
) optionalPolicy ARNs to attach to our created user
Default value:
[ ]
policy_arns_map
(map(string)
) optionalPolicy ARNs to attach (descriptive key => arn)
Default value:
{ }
ssm_base_path
(string
) optionalThe base path for SSM parameters where secrets are stored
Default value:
"/system_user/"
ssm_enabled
(bool
) optionalSet
true
to store secrets in SSM Parameter Store,<br/> false
to store secrets in Terraform state as outputs.
Since Terraform state would contain the secrets in plaintext,
use of SSM Parameter Store is recommended.Default value:
true
ssm_ses_smtp_password_enabled
(bool
) optionalWhether or not to create an SES SMTP password
Default value:
false
Context Variables
The following variables are defined in the context.tf
file of this module and part of the terraform-null-label pattern.
context.tf
file of this module and part of the terraform-null-label pattern.Outputs
access_key_id
The access key ID
access_key_id_ssm_path
The SSM Path under which the IAM User's access key ID is stored
secret_access_key
When
ssm_enabled
isfalse
, this is the secret access key for the IAM user.
This will be written to the state file in plain-text.
Whenssm_enabled
istrue
, this output will be empty to keep the value secure.secret_access_key_ssm_path
The SSM Path under which the IAM User's secret access key is stored
ses_smtp_password_v4
When
ssm_enabled
is false, this is the secret access key converted into an SES SMTP password
by applying AWS's Sigv4 conversion algorithm. It will be written to the Terraform state file in plaintext.
Whenssm_enabled
istrue
, this output will be empty to keep the value secure.ses_smtp_password_v4_ssm_path
The SSM Path under which the IAM User's SES SMTP password is stored
ssm_enabled
true
when secrets are stored in SSM Parameter store,
false
when secrets are stored in Terraform state as outputs.user_arn
The ARN assigned by AWS for this user
user_name
Normalized IAM user name
user_unique_id
The unique ID assigned by AWS
Dependencies
Requirements
terraform
, version:>= 0.13.0
aws
, version:>= 2.0
Providers
aws
, version:>= 2.0
Modules
Name | Version | Source | Description |
---|---|---|---|
store_write | 0.13.0 | cloudposse/ssm-parameter-store/aws | n/a |
this | 0.25.0 | cloudposse/label/null | n/a |
Resources
The following resources are used by this module:
aws_iam_access_key.default
(resource)aws_iam_user.default
(resource)aws_iam_user_policy.inline_policies
(resource)aws_iam_user_policy_attachment.policies
(resource)
Data Sources
The following data sources are used by this module: