AWS IAM User

This page shows how to write Terraform and CloudFormation for IAM User and write them securely.

aws_iam_user (Terraform)

The User in IAM can be configured in Terraform with the resource name aws_iam_user. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

iam_user.tf#L1
resource "aws_iam_user" "AIDAI5VAHO4Y6DRKF6X3Y" {
  name = "gamelift_player"
  path = "/"
  tags {}
}

iam_user.tf#L1
resource "aws_iam_user" "AIDAI5VAHO4Y6DRKF6X3Y" {
  name = "gamelift_player"
  path = "/"
  tags = {}
}

iam_user.tf#L1
resource "aws_iam_user" "AIDAI5VAHO4Y6DRKF6X3Y" {
  name = "gamelift_player"
  path = "/"
  tags {}
}

_users.tf#L1
resource "aws_iam_user" "phisinee_s" {
  name = "phisinee.s"

  tags = {
    email = "ange.l@pomelofashion.com"
  }
users-travis-ci.tf#L9
resource "aws_iam_user" "travis_ci_ack" {
  name = "travis-ci-ack"
}

resource "aws_iam_user" "travis_ci_aws_billing_alerts" {
  name = "travis-ci-aws-billing-alerts"

Parameters

Explanation in Terraform Registry

Provides an IAM user.

NOTE: If policies are attached to the user via the aws_iam_policy_attachment resource and you are modifying the user name or path, the force_destroy argument must be set to true and applied before attempting the operation otherwise you will encounter a DeleteConflict error. The aws_iam_user_policy_attachment resource (recommended) does not have this requirement.

AWS::IAM::User (CloudFormation)

The User in IAM can be configured in CloudFormation with the resource name AWS::IAM::User. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

training-prime.yml#L3
    Type: "AWS::IAM::User"
    Properties:
      Groups:
        - Devusers
        - Produsers
        - PrimeUsers
training-prime.yml#L3
    Type: "AWS::IAM::User"
    Properties:
      Groups:
        - DevUsers
        - ProdUsers
        - PrimeUsers
training-prime.yml#L3
    Type: "AWS::IAM::User"
    Properties:
      Groups:
        - DevUsers
        - ProdUsers
        - PrimeUsers
training-prime.yml#L3
    Type: "AWS::IAM::User"
    Properties:
      Groups:
        - Devusers
        - Produsers
        - PrimeUsers
training-prime.yml#L3
    Type: "AWS::IAM::User"
    Properties:
      Groups:
        - DevUsers
        - ProdUsers
        - PrimeUsers
Identity-CustomUsers.json#L73
      "Type" : "AWS::IAM::User",
      "Properties" : {
        "UserName" : "applicationadministrator",
        "Path" : "/",
        "Groups" : [
          { "Fn::ImportValue" : { "Fn::Sub" : "${CustomGroupsStackName}-ApplicationAdministratorsGroup" }}
Identity-CustomUsers.json#L73
      "Type" : "AWS::IAM::User",
      "Properties" : {
        "UserName" : "applicationadministrator",
        "Path" : "/",
        "Groups" : [
          { "Fn::ImportValue" : { "Fn::Sub" : "${CustomGroupsStackName}-ApplicationAdministratorsGroup" }}
cf-example-100.json#L6
            "Type": "AWS::IAM::User",
            "Properties": {
                "UserName": "TestUser1",
                "Path": "/"
            }
        },
Scout2-Master-004-IAMUsers-Global-Wait.json#L6
            "Type": "AWS::IAM::User",
            "Properties": {
                "UserName": "Scout2User001",
                "Groups": [
                    "BlockedUsers"
                ]
Identity-CustomUsers.json#L46
      "Type" : "AWS::IAM::User",
      "Properties" : {
        "UserName" : "mcrawford",
        "Path" : "/",
        "Groups" : [{ "Fn::ImportValue" : { "Fn::Sub" : "${StandardGroupsStackName}-AdministratorsGroup" }}]
      }

Parameters

Explanation in CloudFormation Registry

Creates a new IAM user for your AWS account. For information about quotas for the number of IAM users you can create, see IAM and AWS STS quotas in the IAM User Guide.

Frequently asked questions

What is AWS IAM User?

AWS IAM User is a resource for IAM of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS IAM User?

For Terraform, the mortyre/misc, mortyre/misc and mortyre/misc source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the ServerlessOpsIO/infrastructure, ServerlessOpsIO/infrastructure and ServerlessOpsIO/infrastructure source code examples are useful. See the CloudFormation Example section for further details.