generated from cloudposse-terraform-components/template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: remove policy files and simplify providers #61
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
+482
−195
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b51ca8b
refactor: remove policy files and simplify providers configuration
Benbentwo d38bd92
chore: move policy files to mixins and restore account_map_enabled de…
Benbentwo 727df2e
docs: add v2.0.0 changelog, migration guide, and update mixins README
Benbentwo e319fc0
docs: update README.yaml for v2.0.0
Benbentwo 64e633c
fix: add version pin to cloudposse/label/null module
Benbentwo 3c328be
docs: regenerate README.md from README.yaml
Benbentwo 5845247
docs: add terraform permission variables to TerraformUpdateAccess docs
Benbentwo 2084694
docs: fix iam_roles module version in README.md
Benbentwo bccfdfd
docs: add hcl language tag to code block in README
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,102 +1,37 @@ | ||
| # This is the default providers.tf when account map is disabled. | ||
|
|
||
| variable "account_map_enabled" { | ||
| type = bool | ||
| description = <<-EOT | ||
| When true, uses the account-map component to look up account IDs dynamically. | ||
| When false, uses the static account_map variable instead. Set to false when | ||
| using Atmos Auth profiles and static account mappings. | ||
| EOT | ||
| default = true | ||
| description = "Enable the account map component" | ||
| default = false | ||
| } | ||
|
|
||
| variable "account_map" { | ||
| type = object({ | ||
| full_account_map = map(string) | ||
| audit_account_account_name = optional(string, "") | ||
| root_account_account_name = optional(string, "") | ||
| full_account_map = map(string) | ||
| audit_account_account_name = optional(string, "") | ||
| root_account_account_name = optional(string, "") | ||
| identity_account_account_name = optional(string, "") | ||
| aws_partition = optional(string, "aws") | ||
| iam_role_arn_templates = optional(map(string), {}) | ||
| }) | ||
| description = <<-EOT | ||
| Static account map used when account_map_enabled is false. | ||
| Provides account name to account ID mapping without requiring the account-map component. | ||
| EOT | ||
| description = "Map of account names (tenant-stage format) to account IDs. Used to verify we're targeting the correct AWS account. Optional attributes support component-specific functionality (e.g., audit_account_account_name for cloudtrail, root_account_account_name for aws-sso)." | ||
| default = { | ||
| full_account_map = {} | ||
| audit_account_account_name = "" | ||
| root_account_account_name = "" | ||
| full_account_map = {} | ||
| audit_account_account_name = "" | ||
| root_account_account_name = "" | ||
| identity_account_account_name = "" | ||
| aws_partition = "aws" | ||
| iam_role_arn_templates = {} | ||
| } | ||
| } | ||
|
|
||
| # This component is unusual in that part of it must be deployed to the `root` | ||
| # account. You have the option of where to deploy the remaining part, and | ||
| # Cloud Posse recommends you deploy it also to the `root` account, however | ||
| # it can be deployed to the `identity` account instead. In the discussion | ||
| # below, when we talk about where this module is being deployed, we are | ||
| # referring to the part of the module that is not deployed to the `root` | ||
| # account and is configured by setting `stage` etc.. | ||
|
|
||
| # If you have Dynamic Terraform Roles enabled, leave the backend `role_arn` at | ||
| # its default value. If deploying only to the `root` account, leave `privileged: false` | ||
| # and use either SuperAdmin or an appropriate `aws-team` (such as `managers`). | ||
| # If deploying to the `identity` account, set `privileged: true` | ||
| # and use SuperAdmin or any other role in the `root` account with Admin access. | ||
| # | ||
| # For those not using dynamic Terraform roles: | ||
| # | ||
| # Set the stack configuration for this component to set `privileged: true` | ||
| # and backend `role_arn` to `null`, and deploy it using either the SuperAdmin | ||
| # role or any other role in the `root` account with Admin access. | ||
| # | ||
| # If you are deploying this to the "identity" account and have a team empowered | ||
| # to deploy to both the "identity" and "root" accounts, then you have the option to set | ||
| # `privileged: false` and leave the backend `role_arn` at its default value, but | ||
| # then SuperAdmin will not be able to deploy this component, | ||
| # only the team with access to both accounts will be able to deploy it. | ||
| # | ||
|
|
||
| provider "aws" { | ||
| region = var.region | ||
|
|
||
| profile = !var.privileged && module.iam_roles.profiles_enabled ? module.iam_roles.terraform_profile_name : null | ||
| dynamic "assume_role" { | ||
| for_each = !var.privileged && module.iam_roles.profiles_enabled ? [] : ( | ||
| var.privileged ? compact([module.iam_roles.org_role_arn]) : compact([module.iam_roles.terraform_role_arn]) | ||
| ) | ||
| content { | ||
| role_arn = assume_role.value | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| # dummy module to satisfy the module dependency | ||
| module "iam_roles" { | ||
| source = "../account-map/modules/iam-roles" | ||
| privileged = var.privileged | ||
|
|
||
| context = module.this.context | ||
| } | ||
|
|
||
| provider "aws" { | ||
| alias = "root" | ||
| region = var.region | ||
|
|
||
| profile = !var.privileged && module.iam_roles_root.profiles_enabled ? module.iam_roles_root.terraform_profile_name : null | ||
| dynamic "assume_role" { | ||
| for_each = !var.privileged && module.iam_roles_root.profiles_enabled ? [] : ( | ||
| var.privileged ? compact([module.iam_roles_root.org_role_arn]) : compact([module.iam_roles_root.terraform_role_arn]) | ||
| ) | ||
| content { | ||
| role_arn = assume_role.value | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| module "iam_roles_root" { | ||
| source = "../account-map/modules/iam-roles" | ||
|
|
||
| privileged = var.privileged | ||
| tenant = module.iam_roles.global_tenant_name | ||
| stage = module.iam_roles.global_stage_name | ||
| environment = module.iam_roles.global_environment_name | ||
|
|
||
| source = "cloudposse/label/null" | ||
| context = module.this.context | ||
Benbentwo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Benbentwo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
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.