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
resource "aws_iam_group_membership" "GameDesigners" {
group = "GameDesigners"
name = "GameDesigners"
users = ["tsinitsyna", "mtumin", "araida", "eakimov", "dbalashova", "kdomareva", "pkuznetsov"]
}
resource "aws_iam_group_membership" "GameDesigners" {
group = "GameDesigners"
name = "GameDesigners"
users = ["tsinitsyna", "mtumin", "araida", "eakimov", "dbalashova", "kdomareva", "pkuznetsov"]
}
resource "aws_iam_group_membership" "syssec" {
name = "syssec"
group = "syssec"
users = [
"jrf",
"jill",
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
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.
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.
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
Type: AWS::IAM::Group
Properties:
GroupName: LockitTest1DevReadGroup
Path: /Lockit/
Policies:
- PolicyName: LockitTest1DevReadPolicy
Type: "AWS::IAM::Group"
Properties:
GroupName: PrimeAdmins
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess
Type: AWS::IAM::Group
Properties:
GroupName: Admins
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess
Type: AWS::IAM::Group
Properties:
GroupName: !Ref DevgroupName
AdministratorGroup:
Type: AWS::IAM::Group
Properties:
Type: "AWS::IAM::Group"
Properties:
GroupName: "groupA"
groupB:
Type: "AWS::IAM::Group"
"Type" : "AWS::IAM::Group"
},
"S3MetadataGroupPolicies" : {
"Type" : "AWS::IAM::Policy",
"Properties" : {
"PolicyName" : "s3-metadata",
"Type": "AWS::IAM::Group",
"Properties": {
"GroupName": "AdminAccessGroup",
"ManagedPolicyArns": ["arn:aws:iam::aws:policy/AdministratorAccess"]
}
},
"Type": "AWS::IAM::Group",
"Properties": {
"GroupName": "BlockedUsers",
"ManagedPolicyArns": [
{ "Fn::ImportValue": "DenyAllPolicyArn" }
]
"Type" : "AWS::IAM::Group",
"Properties" : {
"GroupName" : "Administrators",
"Path" : "/",
"ManagedPolicyArns" : [
"arn:aws:iam::aws:policy/AdministratorAccess"
"Type": "AWS::IAM::Group",
"Properties": {
"GroupName": "groupA"
}
},
Parameters
-
GroupName
optional - String -
ManagedPolicyArns
optional - List -
Path
optional - String -
Policies
optional - List of Policy
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.