aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

[AWS::AutoScaling::AutoScalingGroup] - [BUG] - CloudControl patch updates fail when updating LaunchTemplate.Version

Open
#2,089 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::AutoScaling::AutoScalingGroup

### Resource Name

AWS::AutoScaling::AutoScalingGroup

### Issue Description

This issue was original reported in the [pulumi-aws-native]() repo which uses AWS CloudControl. If you create an AutoScalingGroup which uses a LaunchTemplate and then you try and update the LaunchTemplate.Version you get the below error message

```console
"InvalidRequest": To describe the launch template data for all your launch templates, for ‘--versions’ specify ‘$Latest’, ‘$Default’, or both, and omit ‘--launch-template-id’, ‘--launch-template-name’, and version numbers. To describe the launch template data for a specific launch template, specify ‘--launch-template-id’ or ‘--launch-template-name’, and for ‘--versions’ specify one or more of the following values: ‘$Latest’, ‘$Default’, or one or more version numbers. (Service: Ec2, Status Code: 400, Request ID: 1741577d-4012-4545-bcf4-e25ecfa1b04a)
```

### Expected Behavior

You should be able to update the LaunchTemplate.Version on the AutoScalingGroup

### Observed Behavior

Fails with the mentioned error message

### Test Cases

1. Create a Launch Template and AutoScaling Group

```yaml
---
Resources:
EC2SecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
VpcId:
Ref: "EC2VPC"
MyLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
UserData: "#!/bin/bash\necho 43"
ImageId: resolve:ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64
InstanceType: t2.micro
SecurityGroupIds:
- Ref: "EC2SecurityGroup"
AutoScalingAutoScalingGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
Properties:
AvailabilityZones:
- "us-east-2b"
DesiredCapacity: "1"
MaxSize: "2"
MinSize: "1"
LaunchTemplate:
Version: !GetAtt MyLaunchTemplate.LaunchTemplateVersion
LaunchTemplateId: !GetAtt MyLaunchTemplate.LaunchTemplateId
VPCZoneIdentifier:
- Ref: "EC2Subnet"
EC2VPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.0.0/16"
EC2Subnet:
Type: "AWS::EC2::Subnet"
Properties:
VpcId:
Ref: "EC2VPC"
CidrBlock: "10.0.160.0/20"
```

2. Create a new version of the LaunchTemplate
3. Try and update the AutoScalingGroup with the new version
```console
$ aws cloudcontrol update-resource --type-name AWS::AutoScaling::AutoScalingGroup --identifier REPLACE_WITH_IDENTIFIER --patch-document '[{"op":"replace","path":"/LaunchTemplate","value":{"LaunchTemplateId":"REPLACE_WITH_ID","Version":3}}]","TypeName":"AWS::AutoScaling::AutoScalingGroup"}]'
```
4. View failed status
```console
$ aws cloudcontrol list-resource-requests --resource-request-status-filter Operations=UPDATE,OperationStatuses=FAILED --query 'ResourceRequestStatusSummaries[?TypeName==`AWS::AutoScaling::AutoScalingGroup`]'
```

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the AWS::AutoScaling::AutoScalingGroup update with AWS CloudControl using the YAML example and the aws cloudcontrol update-resource command. Compare the failed operation with the expected LaunchTemplate.Version change; done means the update succeeds without the EC2 InvalidRequest error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.