hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.19k forks source link

[New Data Source]: aws eks describe-addon-configuration #39372

Open lapkritinis opened 2 months ago

lapkritinis commented 2 months ago

Description

It fetches default EKS addon configuration. Required for example to fetch coredns default pod tolerations so I can add mine additionally instead of overwriting them or hardcoding them. I think should be simple task to complete - there is Go SDK resource for it: https://pkg.go.dev/github.com/aws/aws-sdk-go@v1.55.5/service/eks#DescribeAddonConfigurationInput

Requested Resource(s) and/or Data Source(s)

"data" "aws_eks_addon_configuration"

Potential Terraform Configuration

"data" "aws_eks_addon_configuration" "this" {
  name = "coredns"
  version = "v1.11.1-eksbuild.8"
}

References

https://docs.aws.amazon.com/cli/latest/reference/eks/describe-addon-configuration.html

Would you like to implement a fix?

None

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

lapkritinis commented 2 months ago

If anyone else struggling with it.. here is a "wrapper" which does same thing:

data "aws_region" "current" {}

data "external" "this" {
  // wrapping response into json as it fails to parse complex json
  program = ["bash", "-c", "aws eks describe-addon-configuration --region ${data.aws_region.current.name} --addon-name ${var.addon_config.name} --addon-version ${var.addon_config.version} --query 'configurationSchema' --output json | jq -R -c '{response: .}'"]
}

output "this" {
  value = jsondecode(jsondecode(data.external.this.result.response)) // double encoded
}

variable "addon_config" {
  type = object({
    name    = string
    version = string
  })
}