Skip to content

Commit

Permalink
udpate assume role setup
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Oct 18, 2023
1 parent 6dcdf8c commit 3c7103c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/kubectl-assume-role/credentials.eks.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
provider "aws" {
alias = "eks"
region = var.region
profile = var.profile

assume_role {
role_arn = format("arn:%v:iam::%v:role/r-inf-terraform", data.aws_arn.current.partition, data.aws_caller_identity.current.account_id)
session_name = var.os_username
}
}

variable "os_environment" {
description = "OS environment variables to pass in with TF_VAR_os_environment={}"
type = map(string)
default = {}
}

variable "os_username" {
description = "OS username $USER pass in as TF_VAR_os_username=$USER"
type = string
default = "UNDEFINED"
}
19 changes: 19 additions & 0 deletions examples/kubectl-assume-role/data.eks-main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
locals {
aws_eks_cluster_auth = data.aws_eks_cluster_auth.cluster
# for main.tf
aws_eks_cluster = aws_eks_cluster.eks_cluster
# for all subdirectories
## aws_eks_cluster = data.aws_eks_cluster.cluster
}

data "aws_eks_cluster_auth" "cluster" {
provider = aws.eks
name = var.cluster_name
}

#---
# for all subdirectories only
#---
## data "aws_eks_cluster" "cluster" {
## name = var.cluster_name
## }
16 changes: 16 additions & 0 deletions examples/kubectl-assume-role/data.eks-subdirectory.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
data "aws_eks_cluster" "cluster" {
name = var.cluster_name
}

data "aws_eks_cluster_auth" "cluster" {
provider = aws.eks
name = var.cluster_name
}

locals {
aws_eks_cluster_auth = data.aws_eks_cluster_auth.cluster
# for main.tf
# aws_eks_cluster = aws_eks_cluster.eks_cluster
# for all subdirectories
aws_eks_cluster = data.aws_eks_cluster.cluster
}

0 comments on commit 3c7103c

Please sign in to comment.