Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-aws-iam
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Terraform Modules
terraform-aws-iam
Commits
283a5142
Unverified
Commit
283a5142
authored
Aug 18, 2020
by
Anton Babenko
Committed by
GitHub
Aug 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: modules/iam-assumable-role-with-oidc: Support multiple provider URLs (#91)
parent
b5bf1cbd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
13 deletions
+28
-13
main.tf
examples/iam-assumable-role-with-oidc/main.tf
+2
-1
README.md
modules/iam-assumable-role-with-oidc/README.md
+3
-2
main.tf
modules/iam-assumable-role-with-oidc/main.tf
+14
-8
variables.tf
modules/iam-assumable-role-with-oidc/variables.tf
+9
-2
No files found.
examples/iam-assumable-role-with-oidc/main.tf
View file @
283a5142
...
...
@@ -17,6 +17,7 @@ module "iam_assumable_role_admin" {
}
provider_url
=
"oidc.eks.eu-west-1.amazonaws.com/id/BA9E170D464AF7B92084EF72A69B9DC8"
provider_urls
=
[
"oidc.eks.eu-west-1.amazonaws.com/id/AA9E170D464AF7B92084EF72A69B9DC8"
]
role_policy_arns
=
[
"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
,
...
...
modules/iam-assumable-role-with-oidc/README.md
View file @
283a5142
...
...
@@ -24,13 +24,14 @@ This module supports IAM Roles for kubernetes service accounts as described in t
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| aws
\_
account
\_
id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider |
`string`
|
`""`
| no |
| aws
\_
account
\_
id | The AWS account ID where the OIDC provider lives, leave empty to use the account fo
r
the AWS provider |
`string`
|
`""`
| no |
| create
\_
role | Whether to create a role |
`bool`
|
`false`
| no |
| force
\_
detach
\_
policies | Whether policies should be detached from this role when destroying |
`bool`
|
`false`
| no |
| max
\_
session
\_
duration | Maximum CLI/API session duration in seconds between 3600 and 43200 |
`number`
|
`3600`
| no |
| oidc
\_
fully
\_
qualified
\_
subjects | The fully qualified OIDC subjects to be added to the role policy |
`set(string)`
|
`[]`
| no |
| oidc
\_
subjects
\_
with
\_
wildcards | The OIDC subject using wildcards to be added to the role policy |
`set(string)`
|
`[]`
| no |
| provider
\_
url | URL of the OIDC Provider |
`string`
| n/a | yes |
| provider
\_
url | URL of the OIDC Provider. Use provider
\_
urls to specify several URLs. |
`string`
|
`""`
| no |
| provider
\_
urls | List of URLs of the OIDC Providers |
`list(string)`
|
`[]`
| no |
| role
\_
name | IAM role name |
`string`
|
`""`
| no |
| role
\_
path | Path of IAM role |
`string`
|
`"/"`
| no |
| role
\_
permissions
\_
boundary
\_
arn | Permissions boundary ARN to use for IAM role |
`string`
|
`""`
| no |
...
...
modules/iam-assumable-role-with-oidc/main.tf
View file @
283a5142
locals
{
aws_account_id
=
var
.
aws_account_id
!
=
""
?
var
.
aws_account_id
:
data
.
aws_caller_identity
.
current
.
account_id
provider_url
=
replace
(
var
.
provider_url
,
"https://"
,
""
)
# clean URLs of https:// prefix
urls
=
[
for
url
in
distinct
(
concat
(
var
.
provider_urls
,
[
var
.
provider_url
]
))
:
replace
(
url
,
"https://"
,
""
)
]
identifiers
=
[
for
url
in
local
.
urls
:
"arn:
${data
.
aws_partition
.
current
.
partition
}
:iam::
${
local
.
aws_account_id
}
:oidc-provider/
${
url
}
"
]
}
data
"aws_caller_identity"
"current"
{}
...
...
@@ -18,26 +26,24 @@ data "aws_iam_policy_document" "assume_role_with_oidc" {
principals
{
type
=
"Federated"
identifiers
=
[
"arn:
${data
.
aws_partition
.
current
.
partition
}
:iam::
${
local
.
aws_account_id
}
:oidc-provider/
${
local
.
provider_url
}
"
]
identifiers
=
local
.
identifiers
}
dynamic
"condition"
{
for_each
=
length
(
var
.
oidc_fully_qualified_subjects
)
>
0
?
[
1
]
:
[]
for_each
=
length
(
var
.
oidc_fully_qualified_subjects
)
>
0
?
local
.
urls
:
[]
content
{
test
=
"StringEquals"
variable
=
"
${
local
.
provider_url
}
:sub"
variable
=
"
${
condition
.
value
}
:sub"
values
=
var
.
oidc_fully_qualified_subjects
}
}
dynamic
"condition"
{
for_each
=
length
(
var
.
oidc_subjects_with_wildcards
)
>
0
?
[
1
]
:
[]
for_each
=
length
(
var
.
oidc_subjects_with_wildcards
)
>
0
?
local
.
urls
:
[]
content
{
test
=
"StringLike"
variable
=
"
${
local
.
provider_url
}
:sub"
variable
=
"
${
condition
.
value
}
:sub"
values
=
var
.
oidc_subjects_with_wildcards
}
}
...
...
modules/iam-assumable-role-with-oidc/variables.tf
View file @
283a5142
...
...
@@ -5,12 +5,19 @@ variable "create_role" {
}
variable
"provider_url"
{
description
=
"URL of the OIDC Provider"
description
=
"URL of the OIDC Provider
. Use provider_urls to specify several URLs.
"
type
=
string
default
=
""
}
variable
"provider_urls"
{
description
=
"List of URLs of the OIDC Providers"
type
=
list
(
string
)
default
=
[]
}
variable
"aws_account_id"
{
description
=
"The AWS account ID where the OIDC provider lives, leave empty to use the account fo the AWS provider"
description
=
"The AWS account ID where the OIDC provider lives, leave empty to use the account fo
r
the AWS provider"
type
=
string
default
=
""
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment