Coder Social home page Coder Social logo

villeneuve-porto / terraform-aws-iam-cross-account-trust-maps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stratusgrid/terraform-aws-iam-cross-account-trust-maps

0.0 0.0 0.0 15 KB

Maps assume role rights to trusted account resources for specific trusting account

License: Apache License 2.0

HCL 100.00%

terraform-aws-iam-cross-account-trust-maps's Introduction

terraform-aws-iam-cross-account-trust-maps

Maps assume role rights to trusted account resources for specific trusting role or multiple trusting roles

Example being used for same account role assumption rights mapping:

module "iam_group_restricted_admin" {
  source  = "StratusGrid/iam-group-with-user-self-service/aws"
  version = "1.0.0"
  name    = "${var.name_prefix}-restricted-admin${local.full_suffix}"
}

module "iam_cross_account_trust_map_restricted_admin" {
  #source              = "StratusGrid/iam-cross-account-trust-maps/aws"
  #version             = "1.1.0"
  source = "github.com/StratusGrid/terraform-aws-iam-cross-account-trust-maps?ref=tf12"

  trusting_role_arn   = module.restricted_admin.role_arn
  trusted_policy_name = module.iam_group_restricted_admin.group_name
  trusted_group_names = [
    "${var.name_prefix}-restricted-admin",
  ]

  require_mfa = true
  input_tags  = merge(local.common_tags, {})
}

Example Single Trusting ARN Usage:

locals {
  trusting_role_arn_other_account = "arn:aws:iam::123456789012:role/cross-account-role-admin"
}

module "iam_cross_account_trust_map" {
  source = "StratusGrid/iam-cross-account-trust-maps/aws"
  version = "2.0.2"
  trusting_role_arn = "${local.trusting_role_arn_other_account}"
  trusted_policy_name = "${replace(local.trusting_role_arn_other_account, "/^([^:]*)+:([^:]*)+:([^:]*)+:([^:]*)+:([^:]*)+:([^/]*)+/([^/]*)$/", "$5-$7")}"
  trusted_group_names = [
    aws_iam_group.mycompany_admins.name
  ]
  trusted_role_names = []
  require_mfa = false  
  input_tags = merge(local.common_tags, {})
}

Example Multiple Trusting ARN Usage:

# This should have each terraform state role if you want a user to be able to apply terraform manually
locals {
  mycompany_organization_terraform_state_account_roles = [
    "arn:aws:iam::123456789012:role/210987654321-terraform-state",
    "arn:aws:iam::123456789012:role/123456789012-terraform-state"
  ]
}

# When require_mfa is set to true, terraform init and terraform apply would need to be run with your STS acquired temporary token
module "mycompany_organization_terraform_state_trust_maps" {
  source = "StratusGrid/iam-role-cross-account-trusting/aws"
  version = "2.0.2"
  trusting_role_arns = local.mycompany_organization_terraform_state_account_roles
  trusted_policy_name = "mycompany-organization-terraform-states"
  trusted_group_names = [
    aws_iam_group.mycompany_internal_admins.name
  ]
  trusted_role_names = []
  require_mfa = false
  input_tags = merge(local.common_tags, {})
}

terraform-aws-iam-cross-account-trust-maps's People

Contributors

stratuschris avatar ivancasco-sg avatar ivancasco avatar mattbarlow-sg 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.