AWS IAM Group Membership

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

aws_iam_group_membership (Terraform)

The Group Membership in IAM can be configured in Terraform with the resource name aws_iam_group_membership. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

iam_group_membership.tf#L1
resource "aws_iam_group_membership" "GameDesigners" {
  group = "GameDesigners"
  name  = "GameDesigners"
  users = ["tsinitsyna", "mtumin", "araida", "eakimov", "dbalashova", "kdomareva", "pkuznetsov"]
}

iam_group_membership.tf#L1
resource "aws_iam_group_membership" "GameDesigners" {
  group = "GameDesigners"
  name  = "GameDesigners"
  users = ["tsinitsyna", "mtumin", "araida", "eakimov", "dbalashova", "kdomareva", "pkuznetsov"]
}

groups.tf#L15
resource "aws_iam_group_membership" "syssec" {
  name = "syssec"
  group = "syssec"
  users = [
    "jrf",
    "jill",
group.tf#L30
resource "aws_iam_group_membership" "administrators" {
  name = "administrators-group-membership"
  group = aws_iam_group.administrators.name
  users = [
    aws_iam_user.adrien_loyer.name,
    aws_iam_user.philippe_blanquet.name

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

  • group required - string
  • id optional computed - string
  • name required - string
  • users required - set of string

Explanation in Terraform Registry

WARNING: Multiple aws_iam_group_membership resources with the same group name will produce inconsistent behavior! Provides a top level resource to manage IAM Group membership for IAM Users. For more information on managing IAM Groups or IAM Users, see [IAM Groups][1] or [IAM Users][2] > > Note: aws_iam_group_membership will conflict with itself if used more than once with the same group. To non-exclusively manage the users in a group, see the [aws_iam_user_group_membership resource][3].

Tips: Best Practices for The Other AWS IAM Resources

In addition to the aws_iam_account_password_policy, AWS IAM has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

aws_iam_account_password_policy

Ensure AWS IAM account password policies requires long passwords

It's better to enforce the use of long and complex passwords to reduce the risk of bruteforce attacks.

Review your AWS IAM settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

AWS::IAM::Group (CloudFormation)

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

Example Usage from GitHub

createProjectCloudformation.yml#L4
      Type: AWS::IAM::Group
      Properties:
        GroupName: LockitTest1DevReadGroup
        Path: /Lockit/
        Policies:
          - PolicyName: LockitTest1DevReadPolicy
groups.yml#L3
    Type: "AWS::IAM::Group"
    Properties:
      GroupName: PrimeAdmins
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AdministratorAccess

dev.yml#L3
    Type: AWS::IAM::Group
    Properties:
      GroupName: Admins
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AdministratorAccess

creategroups.yml#L20
    Type: AWS::IAM::Group
    Properties:
      GroupName: !Ref DevgroupName
  AdministratorGroup:
    Type: AWS::IAM::Group
    Properties:
iam_user_with_two_additions.yml#L14
    Type: "AWS::IAM::Group"
    Properties:
      GroupName: "groupA"

  groupB:
    Type: "AWS::IAM::Group"
group_s3.json#L9
      "Type" : "AWS::IAM::Group"
    },
    "S3MetadataGroupPolicies" : {
      "Type" : "AWS::IAM::Policy",
      "Properties" : {
        "PolicyName" : "s3-metadata",
4-iamgroupspolicies.json#L8
       "Type": "AWS::IAM::Group",
       "Properties": {
          "GroupName": "AdminAccessGroup",
          "ManagedPolicyArns": ["arn:aws:iam::aws:policy/AdministratorAccess"]
       }
    },
Scout2-Master-003-IAMGroups-Global-Wait.json#L6
            "Type": "AWS::IAM::Group",
            "Properties": {
                "GroupName": "BlockedUsers",
                "ManagedPolicyArns": [
                    { "Fn::ImportValue": "DenyAllPolicyArn" }
                ]
Identity-StandardGroups.json#L37
      "Type" : "AWS::IAM::Group",
      "Properties" : {
        "GroupName" : "Administrators",
        "Path" : "/",
        "ManagedPolicyArns" : [
          "arn:aws:iam::aws:policy/AdministratorAccess"
iam_user_with_two_additions.json#L18
      "Type": "AWS::IAM::Group",
      "Properties": {
        "GroupName": "groupA"
      }
    },

Parameters

Explanation in CloudFormation Registry

Creates a new group. For information about the number of groups you can create, see Limitations on IAM Entities in the IAM User Guide.

Frequently asked questions

What is AWS IAM Group Membership?

AWS IAM Group Membership 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 Group Membership?

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

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