Code Monkey home page Code Monkey logo

terraform-aws-iam's Introduction

Terraform AWS IAM Stack

Circle CI

Module stack that supports AWS IAM Role, User, and Group managment. Role, User, and Group Objects are created with policies attached and grouped by effect.

Requirements

  • Terraform 0.6.4 or newer
  • AWS provider

Role Module

The Role module provisions an AWS Role, with support for multiple policy attachment

Input Variables

  • rolename - The name of the role.
  • service - The name of the service the role is for, such as "ec2.amazonaws.com"
  • actions - '/' and ',' separated list of action groups". Action groups are separated by a '/', and individual actions within an action group are seperated by a ','. This allows for efficient grouping of actions into policies by effect.
  • effects - Comma separated list of effects, such as "Allow,Deny". Each item in this list is associated with the action group at the same index.
  • resources - Comma separated list of resource specifications for the action/effect to apply to. Use a resource URN for a specific resource, or "*", to apply to all. Each item in this list is associated with the action group and effect at the same index.

Usage

The example below creates a role named "VolumeManagerRole" in which an instance with this role would be allowed ('Allow' effect) to Describe, Attach, Detach or Create a volume, but would not be allowed ('Deny' effect) to delete or modify a volume

module "volume_admin_role" {

  source = "github.com/unifio/terraform-aws-iam//iam_role"
  rolename = "VolumeManagerRole"
  service = "ec2.amazonaws.com"
  actions = "ec2:DescribeVolume,ec2:AttachVolume,ec2:DetachVolume,ec2:CreateVolume/ec2:DeleteVolume,ec2:ModifyVolumeAttribute"
  effects = "Allow,Deny"
  resources = "*,*,"
}

Outputs

  • role_id - ID of the IAM role
  • role_name - Name of the IAM role
  • role_arn - The ARN (Amazon Resource Name) of the role object created
  • role_policy_ids - Comma separated list of policy ids attached to the role

User Module

The Role module provisions an AWS User, with support for multiple policy attachment

Input Variables

  • username - The name of the role.
  • path - The path to create the user in. Defaults to "/"
  • actions - '/' and ',' separated list of action groups". Action groups are separated by a '/', and individual actions within an action group are seperated by a ','. This allows for efficient grouping of actions into policies by effect. ".
  • effects - Comma separated list of effects, such as "Allow,Allow,Deny". Each item in this list is associated with the action group at the same index.
  • resources - Comma separated list of resource specifications for the action/effect to apply to. Use a resource URN for a specific resource, or "*", to apply to all. Each item in this list is associated with the action group and effect at the same index.

Usage

module "volume_admin_user" {
  source = "github.com/unifio/terraform-aws-iam//iam_user"
  username = "VolumeAdminUser"
  path = "/system/"
  actions = "ec2:Describe*,ec2:AttachVolume,ec2:DetachVolume,ec2:CreateVolume"
  effects = "Allow"
  resources = "*"
}

Outputs

  • user_id - ID of the IAM User
  • user_name - Name of the IAM User
  • user_arn - The ARN (Amazon Resource Name) of the user object created
  • user_access_key_id - Access key for the IAM User
  • user_access_key_secret - Secret key for the IAM User. This is also written to the state file.
  • user_policy_ids - Comma separated list of the policies that are attached to the IAM User.

Group Module

The Role module provisions an AWS Group, adding a list of members, with support for multiple policy attachment

Input Variables

  • groupname - The name of the group.
  • path - The path to create the group in. Defaults to "/"
  • actions - '/' and ',' separated list of action groups". Action groups are separated by a '/', and individual actions within an action group are seperated by a ','. This allows for efficient grouping of actions into policies by effect. ".
  • effects - Comma separated list of effects, such as "Allow,Allow,Deny". Each item in this list is associated with the action group at the same index.
  • resources - Comma separated list of resource specifications for the action/effect to apply to. Use a resource URN for a specific resource, or "*", to apply to all. Each item in this list is associated with the action group and effect at the same index.

Usage

module "volume_admin_group" {
  source = "github.com/unifio/terraform-aws-iam//iam_group"
  groupname = "VolumeAdminGroup"
  path = "/groups/"
  actions = "ec2:Describe*,ec2:AttachVolume,ec2:DetachVolume,ec2:CreateVolume"
  effects = "Allow"
  resources = "*"
  members = "${aws_iam_user.user_one.name},${aws_iam_user.user_two.name}"
}

Outputs

  • group_id - ID of the IAM Group
  • group_name - Name of the IAM Group
  • group_arn - The ARN (Amazon Resource Name) of the user object created
  • group_policy_ids - Comma separated list of the policies that are attached to the IAM Group.

Examples

See the examples directory for a complete set of example source files.

License

MPL 2. See LICENSE for full details.

terraform-aws-iam's People

Contributors

robertys10 avatar

Watchers

James Cloos avatar Maik Ellerbrock avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.