-
-
Notifications
You must be signed in to change notification settings - Fork 367
feat: add EKS Auto Mode support #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
53dbe60
feat: add EKS Auto Mode support
Benbentwo 61b3dea
fix: replace coalesce with ternary for bootstrap_self_managed_addons
Benbentwo edcf6a7
fix: filter auto mode node role from linux access entries
Benbentwo 7f4d7b3
revert: remove submodule-level access entry filtering
Benbentwo eda8a0a
refactor: rename Auto Mode variables with auto_mode_ prefix
Benbentwo f8651ab
feat: add EKS Capabilities support (Argo CD, ACK, KRO)
Benbentwo 8518b52
chore: remove .terraform.lock.hcl from repo
Benbentwo 7a3c39d
feat: update examples/complete with Auto Mode support
Benbentwo 985b221
fix: use static key sets for capabilities for_each to fix plan-time e…
Benbentwo 9e59751
fix: add create_iam_role field to capabilities for plan-time stability
Benbentwo 70ba794
fix: make aws_idc required for Argo CD capability configuration
Benbentwo abbc924
fix: make aws_idc optional for Argo CD -- skip argo_cd block when absent
Benbentwo 8df2a9b
fix: remove unused enabled_capabilities local
Benbentwo 4c111a5
fix: require aws_idc for ARGOCD capabilities, skip empty config block
Benbentwo a2e337d
chore: remove .terraform.lock.hcl from version control
Benbentwo a35c839
docs: add EKS Auto Mode section to README.yaml
Benbentwo d922e7c
fix: use aws_partition for policy ARNs in examples, rename capabiliti…
Benbentwo aeb880d
update test
Benbentwo a07061d
-> local.enabled
Benbentwo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| # EKS Capabilities: Argo CD, ACK, KRO | ||
| # https://docs.aws.amazon.com/eks/latest/userguide/capabilities.html | ||
|
|
||
| locals { | ||
| # Use toset of keys to ensure for_each keys are always known at plan time. | ||
| # The map keys come from var.capabilities which is a static configuration. | ||
| enabled_capability_keys = toset([ | ||
| for k, v in var.capabilities : k if local.enabled && v.enabled | ||
| ]) | ||
|
|
||
| # Keys of capabilities that need auto-created IAM roles. | ||
| # Uses create_iam_role (a static bool) instead of role_arn == null | ||
| # to ensure for_each keys are always known at plan time. | ||
| capability_keys_needing_roles = toset([ | ||
| for k, v in var.capabilities : k if local.enabled && v.enabled && v.create_iam_role | ||
| ]) | ||
|
|
||
| # Final role ARN map: auto-created or user-provided | ||
| capability_role_arns = { | ||
| for k in local.enabled_capability_keys : k => ( | ||
| var.capabilities[k].create_iam_role ? aws_iam_role.capability[k].arn : var.capabilities[k].role_arn | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| # IAM roles for capabilities that don't provide their own | ||
| module "capability_label" { | ||
| for_each = local.capability_keys_needing_roles | ||
|
|
||
| source = "cloudposse/label/null" | ||
| version = "0.25.0" | ||
|
|
||
| attributes = ["capability", each.key] | ||
| context = module.this.context | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "capability_assume_role" { | ||
| count = length(local.capability_keys_needing_roles) > 0 ? 1 : 0 | ||
|
|
||
| statement { | ||
| effect = "Allow" | ||
| actions = ["sts:AssumeRole", "sts:TagSession"] | ||
|
|
||
| principals { | ||
| type = "Service" | ||
| identifiers = ["capabilities.eks.amazonaws.com"] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "aws_iam_role" "capability" { | ||
| for_each = local.capability_keys_needing_roles | ||
|
|
||
| name = module.capability_label[each.key].id | ||
| assume_role_policy = one(data.aws_iam_policy_document.capability_assume_role[*].json) | ||
| tags = module.capability_label[each.key].tags | ||
| permissions_boundary = var.permissions_boundary | ||
| } | ||
|
|
||
| resource "aws_eks_capability" "default" { | ||
| for_each = local.enabled_capability_keys | ||
|
|
||
| cluster_name = local.eks_cluster_id | ||
| capability_name = each.value | ||
| type = var.capabilities[each.value].type | ||
| role_arn = local.capability_role_arns[each.value] | ||
| delete_propagation_policy = var.capabilities[each.value].delete_propagation_policy | ||
| tags = module.label.tags | ||
|
|
||
| dynamic "configuration" { | ||
| # The AWS API requires configuration with argo_cd and aws_idc for ARGOCD capabilities. | ||
| # Skip the entire configuration block if aws_idc is not provided -- the capability | ||
| # cannot be created without it. Provide aws_idc in your stack config to enable. | ||
| for_each = ( | ||
| var.capabilities[each.value].type == "ARGOCD" && | ||
| var.capabilities[each.value].configuration != null && | ||
| try(var.capabilities[each.value].configuration.argo_cd.aws_idc, null) != null | ||
| ) ? [var.capabilities[each.value].configuration] : [] | ||
| content { | ||
| dynamic "argo_cd" { | ||
| for_each = configuration.value.argo_cd != null ? [configuration.value.argo_cd] : [] | ||
| content { | ||
| namespace = argo_cd.value.namespace | ||
|
|
||
| aws_idc { | ||
| idc_instance_arn = argo_cd.value.aws_idc.idc_instance_arn | ||
| idc_region = argo_cd.value.aws_idc.idc_region | ||
| } | ||
|
|
||
| dynamic "network_access" { | ||
| for_each = argo_cd.value.network_access != null ? [argo_cd.value.network_access] : [] | ||
| content { | ||
| vpce_ids = network_access.value.vpce_ids | ||
| } | ||
| } | ||
|
|
||
| dynamic "rbac_role_mapping" { | ||
| for_each = argo_cd.value.rbac_role_mapping | ||
| content { | ||
| role = rbac_role_mapping.value.role | ||
|
|
||
| dynamic "identity" { | ||
| for_each = rbac_role_mapping.value.identity | ||
| content { | ||
| id = identity.value.id | ||
| type = identity.value.type | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| timeouts { | ||
| create = var.capabilities[each.value].create_timeout | ||
| update = var.capabilities[each.value].update_timeout | ||
| delete = var.capabilities[each.value].delete_timeout | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_eks_cluster.default, | ||
| aws_iam_role.capability, | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.