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

EC2 Key Pair creation fails with unhelpful error

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

Description

### Name of the resource

Other

### Resource name

AWS::EC2::KeyPair

### Description

This was originally reported in CDK in [aws/aws-cdk:25929](https://github.com/aws/aws-cdk/issues/25929). When the value of `PublicKeyMaterial` is not well formatted, the creation of `AWS::EC2::KeyPair` fails with unhelpful error like:

```
Resource handler returned message: "null" (RequestToken: c6817ee0-0c65-b552-f35f-336715c567ce, HandlerErrorCode: InvalidRequest)
```

CloudFormation snippet to reproduce:

```yaml
Resources:
MyKeyPair:
Type: AWS::EC2::KeyPair
Properties:
KeyName: keyName
PublicKeyMaterial: somethingInvalid
```

It would be great if CloudFormation propagated the error from the back-end service.

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the provided CloudFormation YAML using AWS::EC2::KeyPair and the invalid PublicKeyMaterial value, then compare the behavior with the linked CDK report. Confirm the backend response and determine whether CloudFormation can expose it instead of returning "null". Done means the same invalid input produces a useful propagated error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.