# Error: Build 'amazon-ebs' errored: Error creating AMI: InvalidAMIName.Malformed

## TL;DR
Your `ami_name` contains characters AWS rejects (like `+` or spaces). Restrict it to letters, numbers, `( ) . - / _`, 3-128 chars, and rebuild.

## The error

```
==> amazon-ebs: Error creating AMI: InvalidAMIName.Malformed: AMI names must be between 3 and 128 characters long, and may contain letters, numbers, '(', ')', '.', '-', '/' and '_'
	status code: 400, request id: OMITTED
Build 'amazon-ebs' errored: Error creating AMI: InvalidAMIName.Malformed
```

## Fix it

1. Inspect your `ami_name`: look for spaces, `+`, or other characters outside the allowed set.
   - Success check: you spot the offending characters (in the issue, `Centos 7 + Stuff`).
2. Sanitize it: replace spaces with `-` or `_`, drop `+` and other symbols. E.g. `centos-7-stuff-{{timestamp}}`.
   - Success check: the name matches `[A-Za-z0-9()./_-]{3,128}`.
3. Note the prevalidation gap: `packer validate` may not catch this; it fails late, after provisioning. Consider it a known rough edge.
   - Success check: you validate names yourself before long builds.
4. Re-run `packer build`.
   - Success check: `Creating the AMI` succeeds.

## When to use this
You hit this at the very end of an amazon-ebs build, after provisioning succeeded, when AWS rejects the AMI name.

## When NOT to use this
Do not use this for `InvalidAMIName.Duplicate` (name taken; make it unique) or for build failures earlier in provisioning.

## Compatibility
Packer 1.x, amazon-ebs. The character rules come from the EC2 API.

## Variants
- `InvalidAMIName.Malformed` from timestamps or variables injecting spaces
- Names over 128 chars from long prefixes plus timestamps

## Root cause
EC2 AMI names allow only a restricted charset. Packer's prevalidation did not reject the bad name, so the build burned full provisioning time before AWS refused it at `CreateImage`.

## Edge cases
- `{{timestamp}}` is safe (digits only). The risk is in your static prefix and variable values.
- Slashes are allowed but can confuse console filtering; prefer `-`.
