# Amazon EKS Blueprints Addon Terraform module
Terraform module which provisions an addon ([Helm release](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release)) and an [IAM role for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).
## Usage
### Create Addon (Helm Release) w/ IAM Role for Service Account (IRSA)
```hcl
module "eks_blueprints_addon" {
source = "aws-ia/eks-blueprints-addon/aws"
version = "~> 1.0" #ensure to update this to the latest/desired version
chart = "karpenter"
chart_version = "0.16.2"
repository = "https://charts.karpenter.sh/"
description = "Kubernetes Node Autoscaling: built for flexibility, performance, and simplicity"
namespace = "karpenter"
create_namespace = true
set = [
{
name = "clusterName"
value = "eks-blueprints-addon-example"
},
{
name = "clusterEndpoint"
value = "https://EXAMPLED539D4633E53DE1B71EXAMPLE.gr7.us-west-2.eks.amazonaws.com"
},
{
name = "aws.defaultInstanceProfile"
value = "arn:aws:iam::111111111111:instance-profile/KarpenterNodeInstanceProfile-complete"
}
]
set_irsa_names = ["serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"]
# # Equivalent to the following but the ARN is only known internally to the module
# set = [{
# name = "serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
# value = iam_role_arn.this[0].arn
# }]
# IAM role for service account (IRSA)
create_role = true
role_name = "karpenter-controller"
role_policies = {
karpenter = "arn:aws:iam::111111111111:policy/Karpenter_Controller_Policy-20221008165117447500000007"
}
oidc_providers = {
this = {
provider_arn = "oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE"
# namespace is inherited from chart
service_account = "karpenter"
}
}
tags = {
Environment = "dev"
}
}
```
### Create Addon (Helm Release) Only
```hcl
module "eks_blueprints_addon" {
source = "aws-ia/eks-blueprints-addon/aws"
version = "~> 1.0" #ensure to update this to the latest/desired version
chart = "metrics-server"
chart_version = "3.8.2"
repository = "https://kubernetes-sigs.github.io/metrics-server/"
description = "Metric server helm Chart deployment configuration"
namespace = "kube-system"
values = [
<<-EOT
podDisruptionBudget:
maxUnavailable: 1
metrics:
enabled: true
EOT
]
set = [
{
name = "replicas"
value = 3
}
]
}
```
### Create IAM Role for Service Account (IRSA) Only
```hcl
module "eks_blueprints_addon" {
source = "aws-ia/eks-blueprints-addon/aws"
version = "~> 1.0" #ensure to update this to the latest/desired version
# Disable helm release
create_release = false
# IAM role for service account (IRSA)
create_role = true
role_name = "aws-vpc-cni-ipv4"
role_policies = {
AmazonEKS_CNI_Policy = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
}
oidc_providers = {
this = {
provider_arn = "oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE"
namespace = "kube-system"
service_account = "aws-node"
}
}
tags = {
Environment = "dev"
}
}
```
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.0 |
| [aws](#requirement\_aws) | >= 4.47 |
| [helm](#requirement\_helm) | >= 2.9 |
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 4.47 |
| [helm](#provider\_helm) | >= 2.9 |
## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [helm_release.this](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.assume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [allow\_self\_assume\_role](#input\_allow\_self\_assume\_role) | Determines whether to allow the role to be [assume itself](https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/) | `bool` | `false` | no |
| [assume\_role\_condition\_test](#input\_assume\_role\_condition\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `"StringEquals"` | no |
| [atomic](#input\_atomic) | If set, installation process purges chart on fail. The wait flag will be set automatically if atomic is used. Defaults to `false` | `bool` | `null` | no |
| [chart](#input\_chart) | Chart name to be installed. The chart name can be local path, a URL to a chart, or the name of the chart if `repository` is specified | `string` | `""` | no |
| [chart\_version](#input\_chart\_version) | Specify the exact chart version to install. If this is not specified, the latest version is installed | `string` | `null` | no |
| [cleanup\_on\_fail](#input\_cleanup\_on\_fail) | Allow deletion of new resources created in this upgrade when upgrade fails. Defaults to `false` | `bool` | `null` | no |
| [create](#input\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |
| [create\_namespace](#input\_create\_namespace) | Create the namespace if it does not yet exist. Defaults to `false` | `bool` | `null` | no |
| [create\_policy](#input\_create\_policy) | Whether to create an IAM policy that is attached to the IAM role created | `bool` | `true` | no |
| [create\_release](#input\_create\_release) | Determines whether the Helm release is created | `bool` | `true` | no |
| [create\_role](#input\_create\_role) | Determines whether to create an IAM role | `bool` | `false` | no |
| [dependency\_update](#input\_dependency\_update) | Runs helm dependency update before installing the chart. Defaults to `false` | `bool` | `null` | no |
| [description](#input\_description) | Set release description attribute (visible in the history) | `string` | `null` | no |
| [devel](#input\_devel) | Use chart development versions, too. Equivalent to version '>0.0.0-0'. If version is set, this is ignored | `bool` | `null` | no |
| [disable\_openapi\_validation](#input\_disable\_openapi\_validation) | If set, the installation process will not validate rendered templates against the Kubernetes OpenAPI Schema. Defaults to `false` | `bool` | `null` | no |
| [disable\_webhooks](#input\_disable\_webhooks) | Prevent hooks from running. Defaults to `false` | `bool` | `null` | no |
| [force\_update](#input\_force\_update) | Force resource update through delete/recreate if needed. Defaults to `false` | `bool` | `null` | no |
| [keyring](#input\_keyring) | Location of public keys used for verification. Used only if verify is true. Defaults to `/.gnupg/pubring.gpg` in the location set by `home` | `string` | `null` | no |
| [lint](#input\_lint) | Run the helm chart linter during the plan. Defaults to `false` | `bool` | `null` | no |
| [max\_history](#input\_max\_history) | Maximum number of release versions stored per release. Defaults to `0` (no limit) | `number` | `null` | no |
| [max\_session\_duration](#input\_max\_session\_duration) | Maximum CLI/API session duration in seconds between 3600 and 43200 | `number` | `null` | no |
| [name](#input\_name) | Name of the Helm release | `string` | `""` | no |
| [namespace](#input\_namespace) | The namespace to install the release into. Defaults to `default` | `string` | `null` | no |
| [oidc\_providers](#input\_oidc\_providers) | Map of OIDC providers where each provider map should contain the `provider_arn`, and `service_accounts` | `any` | `{}` | no |
| [override\_policy\_documents](#input\_override\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank `sid`s will override statements with the same `sid` | `list(string)` | `[]` | no |
| [policy\_description](#input\_policy\_description) | IAM policy description | `string` | `null` | no |
| [policy\_name](#input\_policy\_name) | Name of IAM policy | `string` | `null` | no |
| [policy\_name\_use\_prefix](#input\_policy\_name\_use\_prefix) | Determines whether the IAM policy name (`policy_name`) is used as a prefix | `bool` | `true` | no |
| [policy\_path](#input\_policy\_path) | Path of IAM policy | `string` | `null` | no |
| [policy\_statements](#input\_policy\_statements) | List of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) | `any` | `[]` | no |
| [postrender](#input\_postrender) | Configure a command to run after helm renders the manifest which can alter the manifest contents | `any` | `{}` | no |
| [recreate\_pods](#input\_recreate\_pods) | Perform pods restart during upgrade/rollback. Defaults to `false` | `bool` | `null` | no |
| [render\_subchart\_notes](#input\_render\_subchart\_notes) | If set, render subchart notes along with the parent. Defaults to `true` | `bool` | `null` | no |
| [replace](#input\_replace) | Re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production. Defaults to `false` | `bool` | `null` | no |
| [repository](#input\_repository) | Repository URL where to locate the requested chart | `string` | `null` | no |
| [repository\_ca\_file](#input\_repository\_ca\_file) | The Repositories CA File | `string` | `null` | no |
| [repository\_cert\_file](#input\_repository\_cert\_file) | The repositories cert file | `string` | `null` | no |
| [repository\_key\_file](#input\_repository\_key\_file) | The repositories cert key file | `string` | `null` | no |
| [repository\_password](#input\_repository\_password) | Password for HTTP basic authentication against the repository | `string` | `null` | no |
| [repository\_username](#input\_repository\_username) | Username for HTTP basic authentication against the repository | `string` | `null` | no |
| [reset\_values](#input\_reset\_values) | When upgrading, reset the values to the ones built into the chart. Defaults to `false` | `bool` | `null` | no |
| [reuse\_values](#input\_reuse\_values) | When upgrading, reuse the last release's values and merge in any overrides. If `reset_values` is specified, this is ignored. Defaults to `false` | `bool` | `null` | no |
| [role\_description](#input\_role\_description) | IAM Role description | `string` | `null` | no |
| [role\_name](#input\_role\_name) | Name of IAM role | `string` | `null` | no |
| [role\_name\_use\_prefix](#input\_role\_name\_use\_prefix) | Determines whether the IAM role name (`role_name`) is used as a prefix | `bool` | `true` | no |
| [role\_path](#input\_role\_path) | Path of IAM role | `string` | `"/"` | no |
| [role\_permissions\_boundary\_arn](#input\_role\_permissions\_boundary\_arn) | Permissions boundary ARN to use for IAM role | `string` | `null` | no |
| [role\_policies](#input\_role\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |
| [set](#input\_set) | Value block with custom values to be merged with the values yaml | `any` | `[]` | no |
| [set\_irsa\_names](#input\_set\_irsa\_names) | Value annotations name where IRSA role ARN created by module will be assigned to the `value` | `list(string)` | `[]` | no |
| [set\_sensitive](#input\_set\_sensitive) | Value block with custom sensitive values to be merged with the values yaml that won't be exposed in the plan's diff | `any` | `[]` | no |
| [skip\_crds](#input\_skip\_crds) | If set, no CRDs will be installed. By default, CRDs are installed if not already present. Defaults to `false` | `bool` | `null` | no |
| [source\_policy\_documents](#input\_source\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. Statements must have unique `sid`s | `list(string)` | `[]` | no |
| [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
| [timeout](#input\_timeout) | Time in seconds to wait for any individual kubernetes operation (like Jobs for hooks). Defaults to `300` seconds | `number` | `null` | no |
| [values](#input\_values) | List of values in raw yaml to pass to helm. Values will be merged, in order, as Helm does with multiple `-f` options | `list(string)` | `null` | no |
| [verify](#input\_verify) | Verify the package before installing it. Helm uses a provenance file to verify the integrity of the chart; this must be hosted alongside the chart. For more information see the Helm Documentation. Defaults to `false` | `bool` | `null` | no |
| [wait](#input\_wait) | Will wait until all resources are in a ready state before marking the release as successful. If set to `true`, it will wait for as long as `timeout`. If set to `null` fallback on `300s` timeout. Defaults to `false` | `bool` | `false` | no |
| [wait\_for\_jobs](#input\_wait\_for\_jobs) | If wait is enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as `timeout`. Defaults to `false` | `bool` | `null` | no |
## Outputs
| Name | Description |
|------|-------------|
| [app\_version](#output\_app\_version) | The version number of the application being deployed |
| [chart](#output\_chart) | The name of the chart |
| [iam\_policy](#output\_iam\_policy) | The policy document |
| [iam\_policy\_arn](#output\_iam\_policy\_arn) | The ARN assigned by AWS to this policy |
| [iam\_role\_arn](#output\_iam\_role\_arn) | ARN of IAM role |
| [iam\_role\_name](#output\_iam\_role\_name) | Name of IAM role |
| [iam\_role\_path](#output\_iam\_role\_path) | Path of IAM role |
| [iam\_role\_unique\_id](#output\_iam\_role\_unique\_id) | Unique ID of IAM role |
| [name](#output\_name) | Name is the name of the release |
| [namespace](#output\_namespace) | Name of Kubernetes namespace |
| [revision](#output\_revision) | Version is an int32 which represents the version of the release |
| [values](#output\_values) | The compounded values from `values` and `set*` attributes |
| [version](#output\_version) | A SemVer 2 conformant version string of the chart |
## Community
- [Code of conduct](.github/CODE_OF_CONDUCT.md)
- [Contributing](.github/CONTRIBUTING.md)
- [Security issue notifications](.github/CONTRIBUTING.md#security-issue-notifications)
## License
Apache-2.0 Licensed. See [LICENSE](https://github.com/aws-ia/terraform-aws-eks-blueprints-addon/blob/main/LICENSE).