Skip to content

Commit 95fcfd1

Browse files
Knowledge base updates (#854)
* Updated with the latest changes from the knowledge base discussions. --------- Co-authored-by: docs-sourcer[bot] <99042413+docs-sourcer[bot]@users.noreply.github.com>
1 parent af211f4 commit 95fcfd1

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
hide_table_of_contents: true
3+
hide_title: true
4+
custom_edit_url: null
5+
---
6+
7+
import CenterLayout from "/src/components/CenterLayout"
8+
import GitHub from "/src/components/GitHub"
9+
10+
<head>
11+
<link rel="canonical" href="https://github.com/gruntwork-io/knowledge-base/discussions/722" />
12+
</head>
13+
14+
<CenterLayout>
15+
<span className="searchCategory">Knowledge Base</span>
16+
<h1>Issue removing default Rbac roles created by namespace-role module.</h1>
17+
<GitHub discussion={{"id":"D_kwDOF8slf84AUDfe","number":722,"author":{"login":"sowmyananjundappa"},"title":"Issue removing default Rbac roles created by namespace-role module.","body":"\r\nHello Team, \r\n\r\n [namespace module](https://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace-roles/main.tf#L36) \r\n [parent module](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L9)\r\n\r\nWe are following your example infrastructure-live implementation for our aws services/resource creation linked [here](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L9). I would like to have remove default RBAC roles which has create permission in namespace module.\r\n\r\nI would like to define an input `create_resource = false` in parent module. However available variables [link](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/modules/services/k8s-namespace/variables.tf) does not allow me to define this. \r\nCould you please provide me a solution to define this or an workaround to remove default RBAC Roles linked [here](https://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace-roles/main.tf#L36).\r\n\r\nExample creation of Default RBAC Roles in k8s Namespace\r\n\r\n ```\r\nCREATE THE DEFAULT RBAC ROLES\r\n This defines four default RBAC roles scoped to the namespace:\r\n - namespace-access-all : Admin level permissions on all resources in the namespace.\r\n - namespace-access-read-only: Read only permissions on all resources in the namespace.\r\n - namespace-helm-metadata-access: Minimal permissions for Helm to manage its metadata in this namespace.\r\n - namespace-helm-resource-access: Minimal permissions for Helm to manage resources in this namespace as Helm charts.\r\n\r\n```\r\n \r\n\r\n\r\n\r\n---\r\n\r\n<ins datetime=\"2023-06-02T07:33:08Z\">\r\n <p><a href=\"https://support.gruntwork.io/hc/requests/110216\">Tracked in ticket #110216</a></p>\r\n</ins>\r\n","bodyHTML":"<p dir=\"auto\">Hello Team,</p>\n<p dir=\"auto\"><a href=\"https://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace-roles/main.tf#L36\">namespace module</a><br>\n<a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L9\">parent module</a></p>\n<p dir=\"auto\">We are following your example infrastructure-live implementation for our aws services/resource creation linked <a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L9\">here</a>. I would like to have remove default RBAC roles which has create permission in namespace module.</p>\n<p dir=\"auto\">I would like to define an input <code class=\"notranslate\">create_resource = false</code> in parent module. However available variables <a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/modules/services/k8s-namespace/variables.tf\">link</a> does not allow me to define this.<br>\nCould you please provide me a solution to define this or an workaround to remove default RBAC Roles linked <a href=\"https://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace-roles/main.tf#L36\">here</a>.</p>\n<p dir=\"auto\">Example creation of Default RBAC Roles in k8s Namespace</p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"CREATE THE DEFAULT RBAC ROLES\nThis defines four default RBAC roles scoped to the namespace:\n- namespace-access-all : Admin level permissions on all resources in the namespace.\n- namespace-access-read-only: Read only permissions on all resources in the namespace.\n- namespace-helm-metadata-access: Minimal permissions for Helm to manage its metadata in this namespace.\n- namespace-helm-resource-access: Minimal permissions for Helm to manage resources in this namespace as Helm charts.\n\"><pre class=\"notranslate\"><code class=\"notranslate\">CREATE THE DEFAULT RBAC ROLES\nThis defines four default RBAC roles scoped to the namespace:\n- namespace-access-all : Admin level permissions on all resources in the namespace.\n- namespace-access-read-only: Read only permissions on all resources in the namespace.\n- namespace-helm-metadata-access: Minimal permissions for Helm to manage its metadata in this namespace.\n- namespace-helm-resource-access: Minimal permissions for Helm to manage resources in this namespace as Helm charts.\n\n</code></pre></div>\n<hr>\n<ins datetime=\"2023-06-02T07:33:08Z\">\n <p dir=\"auto\"><a href=\"https://support.gruntwork.io/hc/requests/110216\" rel=\"nofollow\">Tracked in ticket #110216</a></p>\n</ins>","answer":{"body":"You are correct that `create_resources` is not threaded all the way through to the service catalog. However, doing so may not have the intended effect that you want. To recap:\r\n\r\nhttps://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L10\r\n\r\nincludes:\r\n\r\nhttps://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/_envcommon/services/eks-applications-namespace.hcl#L16\r\n\r\nwhich references the k8s-namespace service:\r\n\r\nhttps://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/modules/services/k8s-namespace/main.tf#L29\r\n\r\nwhich not only creates the RBAC roles, but the namespace itself in:\r\n\r\nhttps://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace/main.tf#L41-L66\r\n\r\nPropagating `create_resources` up into the service catalog and then setting it to `false` would then not create the namespace at all, which may not be desirable.\r\n\r\nMy recommendation is to either remove the `k8s-namespace` from `_envcommon` ([here](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/_envcommon/services/eks-applications-namespace.hcl#L16)), or remove it and replace it with the resources that you need. In other words, you might bring the `kubernetes_namespace` resource out of the terraform-kubernetes-namespace module and pull that directly into `_envcommon`, if that's the only thing you need.\r\n\r\nOn our end, I've filed a ticket in https://github.com/gruntwork-io/terraform-kubernetes-namespace/issues/28 for us to consider separate control of the namespace and the namespace roles.","bodyHTML":"<p dir=\"auto\">You are correct that <code class=\"notranslate\">create_resources</code> is not threaded all the way through to the service catalog. However, doing so may not have the intended effect that you want. To recap:</p>\n<p dir=\"auto\"><a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L10\">https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/dev/us-west-2/dev/services/eks-applications-namespace/terragrunt.hcl#L10</a></p>\n<p dir=\"auto\">includes:</p>\n<p dir=\"auto\"><a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/_envcommon/services/eks-applications-namespace.hcl#L16\">https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/_envcommon/services/eks-applications-namespace.hcl#L16</a></p>\n<p dir=\"auto\">which references the k8s-namespace service:</p>\n<p dir=\"auto\"><a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/modules/services/k8s-namespace/main.tf#L29\">https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/modules/services/k8s-namespace/main.tf#L29</a></p>\n<p dir=\"auto\">which not only creates the RBAC roles, but the namespace itself in:</p>\n<p dir=\"auto\"><a href=\"https://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace/main.tf#L41-L66\">https://github.com/gruntwork-io/terraform-kubernetes-namespace/blob/main/modules/namespace/main.tf#L41-L66</a></p>\n<p dir=\"auto\">Propagating <code class=\"notranslate\">create_resources</code> up into the service catalog and then setting it to <code class=\"notranslate\">false</code> would then not create the namespace at all, which may not be desirable.</p>\n<p dir=\"auto\">My recommendation is to either remove the <code class=\"notranslate\">k8s-namespace</code> from <code class=\"notranslate\">_envcommon</code> (<a href=\"https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/_envcommon/services/eks-applications-namespace.hcl#L16\">here</a>), or remove it and replace it with the resources that you need. In other words, you might bring the <code class=\"notranslate\">kubernetes_namespace</code> resource out of the terraform-kubernetes-namespace module and pull that directly into <code class=\"notranslate\">_envcommon</code>, if that's the only thing you need.</p>\n<p dir=\"auto\">On our end, I've filed a ticket in <a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1741826617\" data-permission-text=\"Title is private\" data-url=\"https://github.com/gruntwork-io/terraform-kubernetes-namespace/issues/28\" data-hovercard-type=\"issue\" data-hovercard-url=\"/gruntwork-io/terraform-kubernetes-namespace/issues/28/hovercard\" href=\"https://github.com/gruntwork-io/terraform-kubernetes-namespace/issues/28\">gruntwork-io/terraform-kubernetes-namespace#28</a> for us to consider separate control of the namespace and the namespace roles.</p>"}}} />
18+
19+
</CenterLayout>
20+
21+
22+
<!-- ##DOCS-SOURCER-START
23+
{
24+
"sourcePlugin": "github-discussions",
25+
"hash": "b1b09fc43ea36a649dae72ee00fbcaab"
26+
}
27+
##DOCS-SOURCER-END -->
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
hide_table_of_contents: true
3+
hide_title: true
4+
custom_edit_url: null
5+
---
6+
7+
import CenterLayout from "/src/components/CenterLayout"
8+
import GitHub from "/src/components/GitHub"
9+
10+
<head>
11+
<link rel="canonical" href="https://github.com/gruntwork-io/knowledge-base/discussions/728" />
12+
</head>
13+
14+
<CenterLayout>
15+
<span className="searchCategory">Knowledge Base</span>
16+
<h1>How do I remove a user from Reference Architecture?</h1>
17+
<GitHub discussion={{"id":"D_kwDOF8slf84AUGiY","number":728,"author":{"login":"timrwilliams"},"title":"How do I remove a user from Reference Architecture?","body":"\nI would like to remove a user account from the reference architecture setup. I have removed their entry from users.yml but when running `terragrunt apply` I receive the below error:\r\n\r\n```\r\n Error: Error deleting IAM User x.x: DeleteConflict: Cannot delete entity, must remove tokens from principal first.\r\n│ \tstatus code: 409, request id: e5ca38f3-0059-4fd2-ac39-ae2528dbbeab\r\n```\r\n\r\nI note in the underlying terraform docs there is a mention of a \"force_destroy\" process but not sure how to translate that to the Reference Architecture flow.\n\n---\n\n<ins datetime=\"2023-06-06T08:20:39Z\">\n <p><a href=\"https://support.gruntwork.io/hc/requests/110231\">Tracked in ticket #110231</a></p>\n</ins>\n","bodyHTML":"<p dir=\"auto\">I would like to remove a user account from the reference architecture setup. I have removed their entry from users.yml but when running <code class=\"notranslate\">terragrunt apply</code> I receive the below error:</p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" Error: Error deleting IAM User x.x: DeleteConflict: Cannot delete entity, must remove tokens from principal first.\n│ \tstatus code: 409, request id: e5ca38f3-0059-4fd2-ac39-ae2528dbbeab\"><pre class=\"notranslate\"><code class=\"notranslate\"> Error: Error deleting IAM User x.x: DeleteConflict: Cannot delete entity, must remove tokens from principal first.\n│ \tstatus code: 409, request id: e5ca38f3-0059-4fd2-ac39-ae2528dbbeab\n</code></pre></div>\n<p dir=\"auto\">I note in the underlying terraform docs there is a mention of a \"force_destroy\" process but not sure how to translate that to the Reference Architecture flow.</p>\n<hr>\n<ins datetime=\"2023-06-06T08:20:39Z\">\n <p dir=\"auto\"><a href=\"https://support.gruntwork.io/hc/requests/110231\" rel=\"nofollow\">Tracked in ticket #110231</a></p>\n</ins>","answer":{"body":"Since MFA tokens are likely created outside of Terraform, you will need to delete these prior to running terraform to remove the account.\r\n\r\nI wrote a script for you to handle this a bit easier than Click Ops in the console. I added in deletion of access keys as well, just in case those have to be removed prior to user deletion as well. Extend as you see fit, of course! This script just echoes to the screen, but can trivially be modified to actually run the aws commands.\r\n\r\n```\r\n#!/bin/bash\r\n\r\nuser=$1\r\n\r\nif [[ -z $user ]] ; then\r\n\techo \"Specify user to remove access keys and tokens from.\"\r\n\texit 0\r\nfi\r\n\r\n# Check to see if the user exists\r\naws iam get-user --user-name $user > /dev/null\r\nif [[ $? -ne 0 ]] ; then\r\n\t# If there's an error, we'll see the problem (likely NoSuchEntity) sent to STDERR\r\n\texit 1\r\nfi\r\n\r\nmfas=$(aws iam list-mfa-devices --user-name $user | grep SerialNumber | cut -d : -f 2- | sed 's/[ \",]//g')\r\nfor mfa in $mfas ; do\r\n\techo \"aws iam deactivate-mfa-device --user-name $user --serial-number $mfa\"\r\n\techo \"aws iam delete-virtual-mfa-device --serial-number $mfa\"\r\ndone\r\n\r\nkeys=$(aws iam list-access-keys --user-name $user | grep AccessKeyId | cut -d : -f 2 | sed 's/[ \",]//g')\r\nfor key in $keys ; do\r\n\techo \"aws iam delete-access-key --user-name $user --access-key-id $key\"\r\ndone\r\n```","bodyHTML":"<p dir=\"auto\">Since MFA tokens are likely created outside of Terraform, you will need to delete these prior to running terraform to remove the account.</p>\n<p dir=\"auto\">I wrote a script for you to handle this a bit easier than Click Ops in the console. I added in deletion of access keys as well, just in case those have to be removed prior to user deletion as well. Extend as you see fit, of course! This script just echoes to the screen, but can trivially be modified to actually run the aws commands.</p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"#!/bin/bash\n\nuser=$1\n\nif [[ -z $user ]] ; then\n\techo &quot;Specify user to remove access keys and tokens from.&quot;\n\texit 0\nfi\n\n# Check to see if the user exists\naws iam get-user --user-name $user &gt; /dev/null\nif [[ $? -ne 0 ]] ; then\n\t# If there's an error, we'll see the problem (likely NoSuchEntity) sent to STDERR\n\texit 1\nfi\n\nmfas=$(aws iam list-mfa-devices --user-name $user | grep SerialNumber | cut -d : -f 2- | sed 's/[ &quot;,]//g')\nfor mfa in $mfas ; do\n\techo &quot;aws iam deactivate-mfa-device --user-name $user --serial-number $mfa&quot;\n\techo &quot;aws iam delete-virtual-mfa-device --serial-number $mfa&quot;\ndone\n\nkeys=$(aws iam list-access-keys --user-name $user | grep AccessKeyId | cut -d : -f 2 | sed 's/[ &quot;,]//g')\nfor key in $keys ; do\n\techo &quot;aws iam delete-access-key --user-name $user --access-key-id $key&quot;\ndone\"><pre class=\"notranslate\"><code class=\"notranslate\">#!/bin/bash\n\nuser=$1\n\nif [[ -z $user ]] ; then\n\techo \"Specify user to remove access keys and tokens from.\"\n\texit 0\nfi\n\n# Check to see if the user exists\naws iam get-user --user-name $user &gt; /dev/null\nif [[ $? -ne 0 ]] ; then\n\t# If there's an error, we'll see the problem (likely NoSuchEntity) sent to STDERR\n\texit 1\nfi\n\nmfas=$(aws iam list-mfa-devices --user-name $user | grep SerialNumber | cut -d : -f 2- | sed 's/[ \",]//g')\nfor mfa in $mfas ; do\n\techo \"aws iam deactivate-mfa-device --user-name $user --serial-number $mfa\"\n\techo \"aws iam delete-virtual-mfa-device --serial-number $mfa\"\ndone\n\nkeys=$(aws iam list-access-keys --user-name $user | grep AccessKeyId | cut -d : -f 2 | sed 's/[ \",]//g')\nfor key in $keys ; do\n\techo \"aws iam delete-access-key --user-name $user --access-key-id $key\"\ndone\n</code></pre></div>"}}} />
18+
19+
</CenterLayout>
20+
21+
22+
<!-- ##DOCS-SOURCER-START
23+
{
24+
"sourcePlugin": "github-discussions",
25+
"hash": "0a34105739a8c0e34e4139677d3f4304"
26+
}
27+
##DOCS-SOURCER-END -->

0 commit comments

Comments
 (0)