feat: add instance_profile config field for EC2 Image Builder#203
Merged
Conversation
Wire InstanceProfile through Config struct, viper defaults, and dreadgoad.yaml so `ami build` falls back to the configured IAM instance profile when no --instance-profile flag is passed. Add tests for the Config field (including mapstructure tag validation) and getFlagString precedence logic in a new cmd/ami_test.go.
…ition gofmt requires all fields in a struct to be aligned when any field name widens the column. Re-align MaxRetries through Ludus fields.
d825a33 to
0181c63
Compare
There was a problem hiding this comment.
Pull request overview
Adds configuration support for an EC2 Image Builder IAM instance profile and wires ami build to use it as a fallback when the CLI flag is not provided.
Changes:
- Adds
InstanceProfileto CLI config with Viper defaulting. - Updates
ami buildinstance profile precedence to use flag then config. - Adds sample config entry and unit tests for the new config field/helper behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
dreadgoad.yaml |
Adds top-level instance_profile config entry. |
cli/internal/config/defaults.go |
Adds default empty value for instance_profile. |
cli/internal/config/config.go |
Adds InstanceProfile field to Config. |
cli/internal/config/config_test.go |
Adds tests for the new config field and tag. |
cli/cmd/ami.go |
Wires ami build to fall back to configured instance profile. |
cli/cmd/ami_test.go |
Adds table tests for getFlagString precedence. |
Comments suppressed due to low confidence (1)
dreadgoad.yaml:5
- The CLI-generated default config is hardcoded separately in
cli/cmd/config_cmd.goand is not updated with this new key, sodreadgoad config initwill still create a config that omits the documentedinstance_profileoption. Please keep the checked-in sample and generated default config in sync so users discover the new setting regardless of how they initialize configuration.
instance_profile: WarpgateImageBuilderInstanceProfile # IAM instance profile for EC2 Image Builder
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| env: staging | ||
| provider: aws # Provider: aws, proxmox, ludus | ||
| # region: us-west-2 # Override AWS region (default: from inventory) | ||
| instance_profile: WarpgateImageBuilderInstanceProfile # IAM instance profile for EC2 Image Builder |
| Env string `mapstructure:"env"` | ||
| Provider string `mapstructure:"provider"` | ||
| Region string `mapstructure:"region"` | ||
| InstanceProfile string `mapstructure:"instance_profile"` |
| instanceType: getFlagStringOpt(cmd, "instance-type"), | ||
| profile: getFlagStringOpt(cmd, "profile"), | ||
| instanceProfile: getFlagStringOpt(cmd, "instance-profile"), | ||
| instanceProfile: getFlagString(cmd, "instance-profile", cfg.InstanceProfile, ""), |
l50
pushed a commit
that referenced
this pull request
May 15, 2026
- Add `InstanceProfile` field to `Config` struct with `mapstructure:"instance_profile"` tag - Wire `ami build` to fall back to `cfg.InstanceProfile` via `getFlagString` (flag > config > empty) - Add viper default and `dreadgoad.yaml` entry for `instance_profile` - Add `TestConfigInstanceProfile` (struct field + mapstructure tag validation) and `TestGetFlagString` (4-case precedence table) in new `cmd/ami_test.go` - [x] `go test ./internal/config/` — all pass - [x] `go test ./cmd/` — all pass (including new `TestGetFlagString`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InstanceProfilefield toConfigstruct withmapstructure:"instance_profile"tagami buildto fall back tocfg.InstanceProfileviagetFlagString(flag > config > empty)dreadgoad.yamlentry forinstance_profileTestConfigInstanceProfile(struct field + mapstructure tag validation) andTestGetFlagString(4-case precedence table) in newcmd/ami_test.goTest plan
go test ./internal/config/— all passgo test ./cmd/— all pass (including newTestGetFlagString)🤖 Generated with Claude Code