hashicorp / hashicorp/packer-plugin-amazon

Allow for custom Temporary IAM Instance Prefixes

Open
#495 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
91
Forks
141
Avg merge
2d 18h
Merged PRs (30d)
3

Description

#### Community Note

Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

#### Description

At the moment, when generating temporary IAM instance resources (keypairs, security groups, roles, profiles etc.), the name of the generated resources is always prefixed with `packer` followed by a `-` or `_` then a UUID. It would be useful to either:

A. Provide a complete custom name for each resource. Since these are temporary and should be cleaned up after execution, there should not be concern about naming collision. However, if this could be a some sort of security risk then:
B. Provide a custom prefix for each resource.

#### Use Case(s)

Providing IAM permissions to a subset of resources each containing a given prefix.

#### Potential configuration
Could be called something like `TemporaryIamInstanceConfig` or `TemporaryIamInstancePrefix` if the prefix must be consisent for all temporary resources.
```go
type StepIamInstanceProfile struct {
PollingConfig *AWSPollingConfig
IamInstanceProfile string
SkipProfileValidation bool
TemporaryIamInstancePrefix string
TemporaryIamInstanceProfilePolicyDocument *PolicyDocument
createdInstanceProfileName string
createdRoleName string
createdPolicyName string
roleIsAttached bool
Tags map[string]string
Ctx interpolate.Context
}
...
if s.TemporaryIamInstanceProfilePolicyDocument != nil {
// Create the profile
iamInstancePrefix := "packer"
if s.TemporaryIamInstancePrefix != nil {
iamInstancePrefix = *s.TemporaryIamInstancePrefix
}
profileName := fmt.Sprintf("%s-%s", iamInstancePrefix, uuid.TimeOrderedUUID())
```

#### Potential References
https://github.com/hashicorp/packer-plugin-amazon/blob/main/builder/common/step_iam_instance_profile.go#L60

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.