From aa3729b64919d4e87f74ae1e0f4dcf2f8e567bb2 Mon Sep 17 00:00:00 2001 From: "docs-sourcer[bot]" <99042413+docs-sourcer[bot]@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:02:32 +0000 Subject: [PATCH 1/3] Updated with the latest changes from the knowledge base discussions. --- docs/discussions/knowledge-base/647.mdx | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/discussions/knowledge-base/647.mdx diff --git a/docs/discussions/knowledge-base/647.mdx b/docs/discussions/knowledge-base/647.mdx new file mode 100644 index 0000000000..99c90e96bb --- /dev/null +++ b/docs/discussions/knowledge-base/647.mdx @@ -0,0 +1,27 @@ +--- +hide_table_of_contents: true +hide_title: true +custom_edit_url: null +--- + +import CenterLayout from "/src/components/CenterLayout" +import GitHub from "/src/components/GitHub" + +
+ + + +A customer asked:
\n\n\nI am using
\naws-vaultto manage access to my AWS accounts. When I attempt to run theexeccommand to delete IAM resources, I get a security token error. What do I need to do to be able to delete IAM resources when usingaws-vault?
aws-vault exec <account-profile>-- aws iam list-usersThe temporary session token returned by the AWS STS action GetSessionToken is valid for making API calls to AWS services - with the following important exception:
\n\nYou cannot call any IAM API operations unless MFA authentication information is included in the request.
\n
This causes confusion to users of aws-vault who are using an IAM user in their profile. When they attempt to use calls for IAM they get InvalidClientTokenId, and ultimately are forced to expose their permanent credentials by passing the --no-session flag to their aws-vault exec commands.
See also: 99designs/aws-vault#1056
"}}} /> + +A customer asked:
\n\n\nI am using
\naws-vaultto manage access to my AWS accounts. When I attempt to run theexeccommand to delete IAM resources, I get a security token error. What do I need to do to be able to delete IAM resources when usingaws-vault?
aws-vault exec <account-profile>-- aws iam list-usersThe temporary session token returned by the AWS STS action GetSessionToken is valid for making API calls to AWS services - with the following important exception:
\n\nYou cannot call any IAM API operations unless MFA authentication information is included in the request.
\n
This causes confusion to users of aws-vault who are using an IAM user in their profile. When they attempt to use calls for IAM they get InvalidClientTokenId, and ultimately are forced to expose their permanent credentials by passing the --no-session flag to their aws-vault exec commands.
See also: 99designs/aws-vault#1056
"}}} /> +A customer asked:
\n\n\nI am using
\naws-vaultto manage access to my AWS accounts. When I attempt to run theexeccommand to delete IAM resources, I get a security token error. What do I need to do to be able to delete IAM resources when usingaws-vault?
aws-vault exec <account-profile>-- aws iam list-users
\nThe temporary session token returned by the AWS STS action GetSessionToken is valid for making API calls to AWS services - with the following important exception:
\n\nYou cannot call any IAM API operations unless MFA authentication information is included in the request.
\n
This causes confusion to users of aws-vault who are using an IAM user in their profile. When they attempt to use calls for IAM they get InvalidClientTokenId, and ultimately are forced to expose their permanent credentials by passing the --no-session flag to their aws-vault exec commands.
See also: 99designs/aws-vault#1056
"}}} />So i have my TG directory structure as below
\n.\n├── env1\n│ └── applications\n│ ├── app1\n│ │ └── terragrunt.hcl\n│ ├── app2\n│ │ └── terragrunt.hcl\n│ └── app3\n│ └── terragrunt.hcl\n├── env2\n│ └── applications\n│ └── app1\n│ └── terragrunt.hcl\n├── env3\n├── main.hcl\n└── modules\n ├── app1\n │ ├── main1.tf\n │ └── main2.tf\n └── app2\n └── main2.tf\nI have couple of environments env1, env2, env3. Each env has app1, app2... applications.
\nThe applications/app1, applications/app2 ... directories only contains terragrunt.hcl and a config.tfvars where i set variables relevant to that app.
\nThe terragrunt.hcl file is all same. It simply does a find_in_parent_folders('main.hcl').
The main.hcl simply does a
locals {\n root_dir = get_parent_terragrunt_dir()\n relative_path = path_relative_to_include()\n deployment_path_components = compact(split(\"/\", local.relative_path))\n\n app = reverse(local.deployment_path_components)[0]\n}\n\nterraform {\n source = \"${local.root_dir}/..//modules/${local.app}\"\n}\nThe whole idea is that when i execute terragrunt plan/apply from say app2, it just runs terraform tf files from modules/app2. The config.tfvars of app2 drives what variation of app2 it should provision for that environment.
This works as expected.
\nHowever, Now i have a need to also run terraform tf files from another module (another/main1.tf and another/main2.tf) when I run say app1. So when I run terragrunt plan/apply from say app1, it should copy/run whatever is in modules/app1 + modules/another.
I have tried using dependency which works but i was trying to see if there was a way to perhaps merge the source attribute of terraform block to include both this paths or some other better way of doing it ? I want to keep modules/app1 and modules/another as separate modules and include them both via applications/app1/terragrunt.hcl.
└── modules\n ├── app1\n │ ├── main1.tf\n │ └── main2.tf\n └── app2\n └── main2.tf\n └── another\n └── main1.tf\n └── main2.tf\nI also tried multiple includes within applications/app1/terragrunt.hcl like below. But i noticed that whatever is the second terraform source that gets run. The below would run tf files from modules/another and not from modules/app1
include app {\n terraform {\n source = <path-to-modules/app1> \n }\n}\n\ninclude another {\n terraform {\n source = <path-to-modules/another> \n }\n}\nAny guidance would be much appreciated.
\nThanks.
\nThis is not a supported feature of Terragrunt. The feature request ticket for this is gruntwork-io/terragrunt#1462, but as indicated in this comment, supporting that operating model requires a major overhaul of Terragrunt internals.
\nThe best workaround currently is to generate a Terraform module that calls those modules using module blocks on the fly using generate blocks.
So i have my TG directory structure as below
\n.\n├── env1\n│ └── applications\n│ ├── app1\n│ │ └── terragrunt.hcl\n│ ├── app2\n│ │ └── terragrunt.hcl\n│ └── app3\n│ └── terragrunt.hcl\n├── env2\n│ └── applications\n│ └── app1\n│ └── terragrunt.hcl\n├── env3\n├── main.hcl\n└── modules\n ├── app1\n │ ├── main1.tf\n │ └── main2.tf\n └── app2\n └── main2.tf\nI have couple of environments env1, env2, env3. Each env has app1, app2... applications.
\nThe applications/app1, applications/app2 ... directories only contains terragrunt.hcl and a config.tfvars where i set variables relevant to that app.
\nThe terragrunt.hcl file is all same. It simply does a find_in_parent_folders('main.hcl').
The main.hcl simply does a
locals {\n root_dir = get_parent_terragrunt_dir()\n relative_path = path_relative_to_include()\n deployment_path_components = compact(split(\"/\", local.relative_path))\n\n app = reverse(local.deployment_path_components)[0]\n}\n\nterraform {\n source = \"${local.root_dir}/..//modules/${local.app}\"\n}\nThe whole idea is that when i execute terragrunt plan/apply from say app2, it just runs terraform tf files from modules/app2. The config.tfvars of app2 drives what variation of app2 it should provision for that environment.
This works as expected.
\nHowever, Now i have a need to also run terraform tf files from another module (another/main1.tf and another/main2.tf) when I run say app1. So when I run terragrunt plan/apply from say app1, it should copy/run whatever is in modules/app1 + modules/another.
I have tried using dependency which works but i was trying to see if there was a way to perhaps merge the source attribute of terraform block to include both this paths or some other better way of doing it ? I want to keep modules/app1 and modules/another as separate modules and include them both via applications/app1/terragrunt.hcl.
└── modules\n ├── app1\n │ ├── main1.tf\n │ └── main2.tf\n └── app2\n └── main2.tf\n └── another\n └── main1.tf\n └── main2.tf\nI also tried multiple includes within applications/app1/terragrunt.hcl like below. But i noticed that whatever is the second terraform source that gets run. The below would run tf files from modules/another and not from modules/app1
include app {\n terraform {\n source = <path-to-modules/app1> \n }\n}\n\ninclude another {\n terraform {\n source = <path-to-modules/another> \n }\n}\nAny guidance would be much appreciated.
\nThanks.
\nThis is not a supported feature of Terragrunt. The feature request ticket for this is gruntwork-io/terragrunt#1462, but as indicated in this comment, supporting that operating model requires a major overhaul of Terragrunt internals.
\nThe best workaround currently is to generate a Terraform module that calls those modules using module blocks on the fly using generate blocks.
A customer asked:
\n\n\nHello There! We're getting this error on the CI/CD workflow:
\n
2023-01-27 16:18:51 [INFO] [gruntwork-install] Repository is not public. GITHUB_OAUTH_TOKEN environment variable is required.\n2023-01-27 16:18:51 [INFO] [gruntwork-install] Installing infrastructure-deployer...\n[fetch] time=\"2023-01-27T16:18:51Z\" level=error msg=\"\\nReceived an HTTP 401 Response when attempting to query the repo for its tags.\\n\\nThis means that either your GitHub oAuth Token is invalid, or that the token is valid but is being used to request access\\nto either a public repo or a private repo to which you don't have access.\\n\\nUnderlying error message:\\nReceived HTTP Response 401 while fetching releases for GitHub URL https://api.github.com/repos/gruntwork-io/terraform-aws-ci/tags?per_page=100. Full HTTP response: {\\\"message\\\":\\\"Bad credentials\\\",\\\"documentation_url\\\":\\\"https://docs.github.com/rest\\\"}\\n\\n\"\nError: Process completed with exit code 1.\n","answer":{"body":"The following Gruntworks products use the same general pattern for securely accessing your GitHub repositories when performing a CI/CD job, without dangerously including your secrets in your Docker images or version control: \r\n\r\n* [ECS Deploy Runner](https://docs.gruntwork.io/reference/services/ci-cd-pipeline/ecs-deploy-runner)\r\n* [Pipelines](https://gruntwork.io/pipelines/)\r\n\r\n# General access pattern leveraging a GitHub Personal Access Token\r\n\r\n1. Your machine user's (CI/CD user's) GitHub Personal Access Token (PAT) is stored in AWS Secrets Manager within your Reference Architecture's shared account \r\n2. At runtime, ECS Deploy Runner / Pipelines fetches your GitHub PAT from Secrets Manager and makes it available to the running ECS task. In this way, we load your secret \"just in time\" and it only exists ephemerally within the volatile memory of the running ECS container. \r\n3. The GitHub PAT is used to perform `git` operations such as cloning your infrastructure-live repository into your running task's ECS container so that can be operated on by your pipeline\r\n\r\nTherefore, if you're encountering this error, it means that you need to ensure two different things about your token: \r\n1. [Ensure that your GitHub PAT is valid](https://github.com/gruntwork-io/knowledge-base/discussions/642)\r\n2. [Ensure that your GitHub PAT has the correct scopes attached to it](https://github.com/gruntwork-io/knowledge-base/discussions/643)\r\n\r\nPlease see the linked KB posts to each for guides and demos on how to quickly confirm if either situation applies to your token. ","bodyHTML":"Does anyone have any idea what might be going on?
\n
\nThanks!
The following Gruntworks products use the same general pattern for securely accessing your GitHub repositories when performing a CI/CD job, without dangerously including your secrets in your Docker images or version control:
\n\ngit operations such as cloning your infrastructure-live repository into your running task's ECS container so that can be operated on by your pipelineTherefore, if you're encountering this error, it means that you need to ensure two different things about your token:
\nPlease see the linked KB posts to each for guides and demos on how to quickly confirm if either situation applies to your token.
"}}} /> + +