Giter Club home page Giter Club logo

terraform-aws-terraform-cloud-oidc's Introduction

Hi ๐Ÿ‘‹, I'm Said Sef

Amazon AWS Google Cloud Linux Bash Terraform Terraform Cloud Golang NodeJS Python Docker Kaniko Kubernetes ArgoCD HELM Git GitHub GitLab PostgreSql Redis ElasticSearch Prometheus Grafana Splunk Consul Vault Tekton Jenkins GitHub Actions DroneCI scikit-learn Pandas Jupyter OpenAI

saidsef

saidsef saidsef saidsef saidsef

terraform-aws-terraform-cloud-oidc's People

Contributors

dependabot[bot] avatar douglasnaphas avatar saidsef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terraform-aws-terraform-cloud-oidc's Issues

One OIDC provider and two IAM roles

Feature Request

Description of Problem:

Terraform Cloud allows to specify TFC_AWS_PLAN_ROLE_ARN and TFC_AWS_APPLY_ROLE_ARN for using different IAM roles for different stages.

I thought of using the module for creating two definitions:

  • The first creates OIDC provider for TFC and IAM role with ReadOnly permissions
  • The second does not create the OIDC provider and uses the created in the previous step, but also creates IAM role with AdministratorAccess permissions
#
# Define OIDC provider for TFC and ReadOnly IAM role
#
module "tfc_oidc_provider_and_readonly_role" {
  source  = "saidsef/terraform-cloud-oidc/aws"
  version = "1.7.3"

  attach_admin_policy           = false
  attach_read_only_policy       = true
  
  create_oidc_provider          = true
  enabled                       = true
  
  force_detach_policies         = false
  organisation                  = var.tfc_organization_name
  projects                      = local.tfc_projects
  iam_role_name                 = "terraform-cloud-readonly-iam-role-${local.account_id}"
  iam_role_path                 = "/"
  iam_role_permissions_boundary = ""
  iam_role_policy_arns          = []
  max_session_duration          = 3600
  tags                          = local.tags
  url                           = var.tfc_hostname
}

#
# Define IAM role with admin permissions for existing OIDC provider
#
module "tfc_oidc_provider_admin_role" {
  source  = "saidsef/terraform-cloud-oidc/aws"
  version = "1.7.3"
  depends_on = [
    module.tfc_oidc_provider_and_readonly_role
  ]

  attach_admin_policy           = true
  attach_read_only_policy       = false
  
  create_oidc_provider          = false
  enabled                       = true
  
  force_detach_policies         = false
  organisation                  = var.tfc_organization_name
  projects                      = local.tfc_projects
  iam_role_name                 = "terraform-cloud-admin-iam-role-${local.account_id}"
  iam_role_path                 = "/"
  iam_role_permissions_boundary = ""
  iam_role_policy_arns          = []
  max_session_duration          = 3600
  tags                          = local.tags
  url                           = var.tfc_hostname
}

However, when I run the plan command I receive the following error:

โ•ท
โ”‚ Error: Invalid index
โ”‚ 
โ”‚   on .terraform/modules/tfc_oidc_provider_admin_role/current.tf line 22, in data "aws_iam_policy_document" "assume_role":
โ”‚   22:       values   = [format("%s", one(aws_iam_openid_connect_provider.provider[0].client_id_list))]
โ”‚     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โ”‚     โ”‚ aws_iam_openid_connect_provider.provider is empty tuple
โ”‚ 
โ”‚ The given key does not identify an element in this collection value: the collection has no elements.
โ•ต

Potential Solutions:

I suppose, there might be added a parameter of the module containing the reference to previously defined OIDC provider.

remove default organisation value

Currently there is a default organisation value set - it is set to the current repo organisation name.

Please remove default organisation value and make it required.

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.