[Enhancement]: `aws_elastic_beanstalk_environment` - support the Kubernetes(Cluster) tier and container image application versions
Description
Elastic Beanstalk now supports a Kubernetes environment tier (Cluster Mode) that runs application versions on Amazon EKS, along with container image-backed application versions via ImageConfiguration.
Elastic Beanstalk has released a new environment mode, Beanstalk Cluster, which runs containerised application on a service-managed Amazon EKS Auto Mode cluster. It is exposed through a new environment tier and through application versions backed by a container image rather than a source bundle. Both are GA and published in the AWS SDK for Go v2.
The provider currently cannot express either. aws_elastic_beanstalk_environment rejects the new tier value, and aws_elastic_beanstalk_application_version has no way to point at a container image or to ask Elastic Beanstalk to build one, so a Cluster mode environment cannot be created or managed with Terraform.
A draft implementation covering both resources is already open in #50054.
Affected Resource(s) or Data Source(s)
aws_elastic_beanstalk_environment- newKubernetestier value, newcluster_arnattributeaws_elastic_beanstalk_application_version- newimage_configurationblock, newbuild_arnandimage_uriattributes
Potential Terraform Configuration
resource "aws_elastic_beanstalk_application" "example" {
name = "example"
}
# An application version backed by an image you built and pushed yourself.
resource "aws_elastic_beanstalk_application_version" "example" {
name = "v1"
application = aws_elastic_beanstalk_application.example.name
image_configuration {
source {
uri = "111122223333.dkr.ecr.us-east-1.amazonaws.com/example:1.0.0"
}
}
}
# Or have Elastic Beanstalk build the image from the source bundle.
resource "aws_elastic_beanstalk_application_version" "built" {
name = "v2"
application = aws_elastic_beanstalk_application.example.name
bucket = aws_s3_bucket.example.id
key = aws_s3_object.example.key
image_configuration {
build {
type = "docker"
dockerfile_location = "Dockerfile"
code_build_service_role = aws_iam_role.codebuild.arn
}
}
}
resource "aws_elastic_beanstalk_environment" "example" {
name = "example-env"
application = aws_elastic_beanstalk_application.example.name
version_label = aws_elastic_beanstalk_application_version.example.name
tier = "Kubernetes"
setting {
namespace = "aws:elasticbeanstalk:eks"
name = "cluster-role"
value = aws_iam_role.cluster.arn
}
setting {
namespace = "aws:elasticbeanstalk:eks"
name = "node-role"
value = aws_iam_role.node.arn
}
setting {
namespace = "aws:elasticbeanstalk:eks:environment"
name = "observability-role"
value = aws_iam_role.observability.arn
}
setting {
namespace = "aws:elasticbeanstalk:eks:environment"
name = "service-port"
value = "8080"
}
setting {
namespace = "aws:elasticbeanstalk:eks:environment"
name = "subnets"
value = join(",", aws_subnet.private[*].id)
}
}
output "cluster_arn" {
value = aws_elastic_beanstalk_environment.example.cluster_arn
}References
- AWS SDK for Go v2,
service/elasticbeanstalkv1.43.0 - introducesImageConfiguration,ImageSource,ImageBuildConfiguration,Cluster, and theImageBuildTypeandArchitectureTypeenums CreateApplicationVersionEnvironmentResourceDescription- Configuration options for Beanstalk Cluster environments - the
aws:elasticbeanstalk:eks*namespaces, which are the only ones a Cluster tier environment accepts - Permissions for Beanstalk Cluster - the IAM roles the tier requires
- Draft implementation: #50054
Would you like to implement the enhancement?
Yes
Source: hashicorp/terraform-provider-aws