|
| 1 | +--- |
| 2 | +Title: "Permission Template Data Source" |
| 3 | +Description: |- |
| 4 | + Retrieves an AWS CloudFormation permission template for creating credentials. |
| 5 | +--- |
| 6 | + |
| 7 | +# Permission Template Data Source |
| 8 | + |
| 9 | +This data source enables users get an AWS CloudFormation template for creating the necessary assets in AWS when creating TMC credentials. |
| 10 | + |
| 11 | +**NOTE**: Currently, only the 'AWS_EC2' and 'AWS_EKS' capabilities are supported in conjunction with the 'DATA_PROTECTION' and 'MANAGED_K8S_PROVIDER' providers. |
| 12 | + |
| 13 | +# Data Protection Permission Template |
| 14 | + |
| 15 | +## Example Usage |
| 16 | + |
| 17 | +```terraform |
| 18 | +locals { |
| 19 | + credentials_name = "test-permission-template-data-protection-tf-111" |
| 20 | + tanzu_capability = "DATA_PROTECTION" |
| 21 | + tanzu_provider = "AWS_EC2" |
| 22 | +
|
| 23 | + stack_message = split("\n", aws_cloudformation_stack.crendetials_permission_template.outputs.Message) |
| 24 | + permission_arn = element(local.stack_message, length(local.stack_message) - 1) |
| 25 | +} |
| 26 | +
|
| 27 | +
|
| 28 | +data "tanzu-mission-control_permission_template" "data_protection_permissions" { |
| 29 | + credentials_name = local.credentials_name |
| 30 | + tanzu_capability = local.tanzu_capability |
| 31 | + tanzu_provider = local.tanzu_provider |
| 32 | +} |
| 33 | +
|
| 34 | +
|
| 35 | +resource "aws_cloudformation_stack" "crendetials_permission_template" { |
| 36 | + name = local.credentials_name |
| 37 | + parameters = data.tanzu-mission-control_permission_template.eks_permissions.template_values != null ? data.tanzu-mission-control_permission_template.eks_permissions.template_values : {} |
| 38 | + template_body = base64decode(data.tanzu-mission-control_permission_template.eks_permissions.template) |
| 39 | + capabilities = ["CAPABILITY_NAMED_IAM"] |
| 40 | +} |
| 41 | +
|
| 42 | +resource "tanzu-mission-control_credential" "data_protection_cred" { |
| 43 | + name = local.credentials_name |
| 44 | +
|
| 45 | + spec { |
| 46 | + capability = local.tanzu_capability |
| 47 | + provider = local.tanzu_provider |
| 48 | +
|
| 49 | + data { |
| 50 | + aws_credential { |
| 51 | + iam_role { |
| 52 | + arn = local.permission_arn |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +# EKS Permission Template |
| 61 | + |
| 62 | +## Example Usage |
| 63 | + |
| 64 | +```terraform |
| 65 | +locals { |
| 66 | + credentials_name = "test-permission-template-eks-tf-43" |
| 67 | + tanzu_capability = "MANAGED_K8S_PROVIDER" |
| 68 | + tanzu_provider = "AWS_EKS" |
| 69 | +
|
| 70 | + stack_message = split("\n", aws_cloudformation_stack.crendetials_permission_template.outputs.Message) |
| 71 | + permission_arn = element(local.stack_message, length(local.stack_message) - 1) |
| 72 | +} |
| 73 | +
|
| 74 | +
|
| 75 | +data "tanzu-mission-control_permission_template" "eks_permissions" { |
| 76 | + credentials_name = local.credentials_name |
| 77 | + tanzu_capability = local.tanzu_capability |
| 78 | + tanzu_provider = local.tanzu_provider |
| 79 | +} |
| 80 | +
|
| 81 | +
|
| 82 | +resource "aws_cloudformation_stack" "crendetials_permission_template" { |
| 83 | + name = local.credentials_name |
| 84 | + parameters = data.tanzu-mission-control_permission_template.eks_permissions.template_values != null ? data.tanzu-mission-control_permission_template.eks_permissions.template_values : {} |
| 85 | + template_body = base64decode(data.tanzu-mission-control_permission_template.eks_permissions.template) |
| 86 | + capabilities = ["CAPABILITY_NAMED_IAM"] |
| 87 | +} |
| 88 | +
|
| 89 | +resource "tanzu-mission-control_credential" "aws_eks_cred" { |
| 90 | + name = local.credentials_name |
| 91 | +
|
| 92 | + spec { |
| 93 | + capability = local.tanzu_capability |
| 94 | + provider = local.tanzu_provider |
| 95 | +
|
| 96 | + data { |
| 97 | + aws_credential { |
| 98 | + iam_role { |
| 99 | + arn = local.permission_arn |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +<!-- schema generated by tfplugindocs --> |
| 108 | +## Schema |
| 109 | + |
| 110 | +### Required |
| 111 | + |
| 112 | +- `credentials_name` (String) The name of the credentials to get permission template for. |
| 113 | +- `tanzu_capability` (String) The Tanzu capability of the credentials. |
| 114 | +When tanzu_capability is set to 'DATA_PROTECTION' tanzu_provider must be set to 'AWS_EC2'. |
| 115 | +When tanzu_capability is set to 'MANAGED_K8S_PROVIDER' tanzu_provider must be set to 'AWS_EKS'. |
| 116 | +Valid values are: [DATA_PROTECTION MANAGED_K8S_PROVIDER] |
| 117 | +- `tanzu_provider` (String) The Tanzu provider of the credentials. |
| 118 | +When tanzu_provider is set to 'AWS_EC2' tanzu_capability must be set to 'DATA_PROTECTION'. |
| 119 | +When tanzu_provider is set to 'AWS_EKS' tanzu_capability must be set to 'MANAGED_K8S_PROVIDER'. |
| 120 | +Valid values are: [AWS_EC2 AWS_EKS] |
| 121 | + |
| 122 | +### Read-Only |
| 123 | + |
| 124 | +- `id` (String) The ID of this resource. |
| 125 | +- `template` (String) Base64 encoded permission template. |
| 126 | +- `template_url` (String) URL for permission template. |
| 127 | +- `template_values` (Map of String) Values to be sent as parameters for the template. |
| 128 | +- `undefined_template_values` (Map of String) Values which are not defined in the template parameters definition. |
0 commit comments