aws / aws/aws-cdk

aws-ec2: Import of existing launch template via attributes doesn't work

Open
#26,035 11 comments 0 reactions 1 assignee Claimed by @colifran View on GitHub
@aws-cdk/aws-ec2 bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

CDK function `fromLaunchTemplateAttributes` doesn't import existing templates as expected, when trying to get an already existing launch template by `launchTemplateName` or `launchTemplateId`. It also throws a misleading error message.

### Expected Behavior

CDK returns an object accordingly to the attributes given.

Also: If it can't be found - for whatever reason -, the error message should at least be more precise in so far, that the launch template itself couldn't be found, instead of throwing the misleading `Error: The provided launch template does not expose its user data.` error message.

### Current Behavior

Doesn't return the expected Launch Template reference and CDK therefore can't synthesize with the misleading error message: `Error: The provided launch template does not expose its user data.`

### Reproduction Steps

1) Create a new launch template named `TestTemplate` via AWS console.
2) Set it up accordingly, so that it is useable.
2) Try to import the created launch template via `launchTemplateName` or `launchTemplateid`:

`const importedLaunchTemplate = ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, "ImportedLaunchTemplate", {
launchTemplateName: "TestTemplate",
})`

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.83

### Framework Version

_No response_

### Node.js Version

13.2.1 (22D68)

### OS

Mac

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.