Skip to content

Conversation

Azeezat-git
Copy link

Description

This PR adds support for the userdata_type field in AWS Batch Compute Environment launch templates, as requested in #43937.

What's Changed

  • ✅ Added userdata_type field to LaunchTemplateSpecification schema
  • ✅ Support for EKS_BOOTSTRAP_SH and EKS_NODEADM values
  • ✅ Updated expand/flatten functions for AWS SDK mapping
  • ✅ Added comprehensive unit and integration tests

Relations

Closes #43937

Output from Acceptance Testing

% make testacc TESTARGS='-run=TestAccBatchComputeEnvironment_launchTemplateUserdataType' PKG=batch ACCTEST_PARALLELISM=4
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 feature/add-batch-userdata-type 🌿...
TF_ACC=1 go1.24.6 test ./internal/service/batch/... -v -count 1 -parallel 4  -run=TestAccBatchComputeEnvironment_launchTemplateUserdataType -timeout 360m -vet=off
2025/09/20 16:56:23 Creating Terraform AWS Provider (SDKv2-style)...
2025/09/20 16:56:23 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccBatchComputeEnvironment_launchTemplateUserdataType
=== PAUSE TestAccBatchComputeEnvironment_launchTemplateUserdataType
=== CONT  TestAccBatchComputeEnvironment_launchTemplateUserdataType
--- PASS: TestAccBatchComputeEnvironment_launchTemplateUserdataType (39.47s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/batch      44.797s

Output from Unit Testing

% go test ./internal/service/batch -v -run=TestExpandLaunchTemplateSpecificationUpdate
2025/09/20 16:35:53 Creating Terraform AWS Provider (SDKv2-style)...
2025/09/20 16:35:53 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestExpandLaunchTemplateSpecificationUpdate
=== PAUSE TestExpandLaunchTemplateSpecificationUpdate
=== CONT  TestExpandLaunchTemplateSpecificationUpdate
--- PASS: TestExpandLaunchTemplateSpecificationUpdate (0.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/batch   

Example Usage

resource "aws_batch_compute_environment" "example" {
  name = "batch-eks-example"

  eks_configuration {
    eks_cluster_arn      = "arn:aws:eks:region:account:cluster/your-cluster"
    kubernetes_namespace = "batch-namespace"
  }

  compute_resources {
    type                = "EC2"
    allocation_strategy = "BEST_FIT_PROGRESSIVE"
    min_vcpus           = 0
    max_vcpus           = 128
    instance_type       = ["m5"]
    subnets             = ["subnet-12345678"]
    instance_role       = "arn:aws:iam::account:instance-profile/your-profile"

    ec2_configuration {
      image_type = "EKS_AL2023"
    }

    launch_template {
      launch_template_name = aws_launch_template.example.name
      version              = aws_launch_template.example.latest_version
      userdata_type        = "EKS_NODEADM"  # NEW FIELD!
    }
  }

  service_role = "arn:aws:iam::account:role/aws-service-role/batch.amazonaws.com/AWSServiceRoleForBatch"
  type         = "MANAGED"
}

References

- Add userdata_type field to LaunchTemplateSpecification schema
- Support EKS_BOOTSTRAP_SH and EKS_NODEADM values
- Add validation for valid userdata_type values
- Update expand/flatten functions for proper AWS SDK mapping
- Add comprehensive unit and integration tests

Closes hashicorp#43937
@Azeezat-git Azeezat-git requested a review from a team as a code owner September 20, 2025 14:01
Copy link
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

Copy link
Contributor

github-actions bot commented Sep 20, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/batch Issues and PRs that pertain to the batch service. size/L Managed by automation to categorize the size of a PR. labels Sep 20, 2025
…onment

- Add changelog entry for hashicorp#43937
- Documents new userdata_type field for launch templates
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/batch Issues and PRs that pertain to the batch service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for "userdataType": "EKS_NODEADM" in for AWS Batch launch templates
2 participants