hashicorp / hashicorp/packer-plugin-amazon
amazon-ebs builder does not accept "/" in instanceProfileName
- Dominant language
- Go
- Stars
- 91
- Forks
- 141
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 3
Description
_This issue was originally opened by @yogeek as hashicorp/packer#10024. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). The original body of the issue is below._
#### Overview of the Issue
When trying to create an AWS AMI with an instance profile ARN with a path (containing "/" characters) like `arn:aws-cn:iam::$ACCOUNT_ID:instance-profile/foo/bar/test-profile`, the following error occurs :
```
Couldn't find specified instance profile: ValidationError: 1 validation error detected: Value '/foo/bar/test-profile' at 'instanceProfileName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w+=,.@-]+
```
#### Reproduction Steps
Try to build an AWS AMI with the code provided in the **Simplified Packer Buildfile** section where `iam_instance_profile` value contains "/" characters :
`"iam_instance_profile": "/foo/bar/test-profile",`
### Packer version
`Packer v1.6.4`
### Simplified Packer Buildfile
```
{
"min_packer_version": "1.3.0",
"variables": {
"aws_region": "{{ env `AWS_DEFAULT_REGION` }}",
"aws_profile": "{{ env `AWS_PROFILE` }}",
[...]
},
"builders": [
{
"type": "amazon-ebs",
"region": "{{user `aws_region`}}",
"instance_type": "t3.micro",
"associate_public_ip_address": true,
"ssh_interface" : "public_ip",
"iam_instance_profile": "/foo/bar/test-profile",
[...]
```
### Log Fragments and crash.log files
```
2020/10/01 16:30:13 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/10/01 16:30:13 machine readable: amazon-ebs,error []string{"Couldn't find specified instance profile: ValidationError: 1 validation error detected: Value '/foo/bar/test-profile' at 'instanceProfileName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\w+=,.@-]+\n\tstatus code: 400, request id: bbc5a9f9-2be5-4ad1-80be-e319b953f7a5"}
status code: 400, request id: bbc5a9f9-2be5-4ad1-80be-e319b953f7a5
==> Builds finished but no artifacts were created.
2020/10/01 16:30:13 [INFO] (telemetry) Finalizing.
Build 'amazon-ebs' errored after 20 seconds 62 milliseconds: Couldn't find specified instance profile: ValidationError: 1 validation error detected: Value '/foo/bar/test-profile' at 'instanceProfileName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w+=,.@-]+
status code: 400, request id: bbc5a9f9-2be5-4ad1-80be-e319b953f7a5
==> Wait completed after 20 seconds 62 milliseconds
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Couldn't find specified instance profile: ValidationError: 1 validation error detected: Value '/foo/bar/test-profile' at 'instanceProfileName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w+=,.@-]+
status code: 400, request id: bbc5a9f9-2be5-4ad1-80be-e319b953f7a5
```
Contributor guide
Assessment
This issue has not been assessed yet.