Describe the bug
The marketplaceProductCodes field in the instance identity document structure is typed as a string. This doesn't match the structure of the real document, in which it is a list of strings (as documented).
Steps to reproduce
Create a file overrides.json with the following contents:
The program exits with an error message about the type of the marketplaceProductCodes field.
Expected outcome
The application starts up and serves the supplied instance identity document.
Application Logs
$ ec2-metadata-mock -c overrides.json
Using configuration from file: overrides.json
Error: Fatal error while attempting to load viper config: 1 error(s) decoding:
* 'dynamic.values.instance-identity-document.MarketplaceProductCodes' expected type 'string', got unconvertible type '[]interface {}', value: '[4i20ezfza3p7xx2kt2g8weu2u]'
Usage:
ec2-metadata-mock <command> [arguments] [flags]
ec2-metadata-mock [command]
Examples:
ec2-metadata-mock --mock-delay-sec 10 mocks all metadata paths
ec2-metadata-mock spot --action terminate mocks spot ITN only
Available Commands:
completion generate the autocompletion script for the specified shell
events Mock EC2 maintenance events
help Help about any command
spot Mock EC2 Spot interruption notice
Flags:
-c, --config-file string config file for cli input parameters in json format (default: $HOME/aemm-config.json)
-h, --help help for ec2-metadata-mock
-n, --hostname string the HTTP hostname for the mock url (default: 0.0.0.0)
-I, --imdsv2 whether to enable IMDSv2 only, requiring a session token when submitting requests (default: false, meaning both IMDS v1 and v2 are enabled)
-d, --mock-delay-sec int spot itn delay in seconds, relative to the application start time (default: 0 seconds)
-x, --mock-ip-count int number of IPs in a cluster that can receive a Spot Interrupt Notice and/or Scheduled Event (default 2)
--mock-trigger-time string spot itn trigger time in RFC3339 format. This takes priority over mock-delay-sec (default: none)
-p, --port string the HTTP port where the mock runs (default: 1338)
--rebalance-delay-sec int rebalance rec delay in seconds, relative to the application start time (default: 0 seconds)
--rebalance-trigger-time string rebalance rec trigger time in RFC3339 format. This takes priority over rebalance-delay-sec (default: none)
-s, --save-config-to-file whether to save processed config from all input sources in .ec2-metadata-mock/.aemm-config-used.json in $HOME or working dir, if homedir is not found (default: false)
-v, --version version for ec2-metadata-mock
Use "ec2-metadata-mock [command] --help" for more information about a command.
panic: Fatal error while executing the root command: Fatal error while attempting to load viper config: 1 error(s) decoding:
* 'dynamic.values.instance-identity-document.MarketplaceProductCodes' expected type 'string', got unconvertible type '[]interface {}', value: '[4i20ezfza3p7xx2kt2g8weu2u]'
goroutine 1 [running]:
main.main()
/amazon-ec2-metadata-mock/cmd/amazon-ec2-metadata-mock.go:25 +0x73
Describe the bug The
marketplaceProductCodes
field in the instance identity document structure is typed as a string. This doesn't match the structure of the real document, in which it is a list of strings (as documented).Steps to reproduce
Create a file
overrides.json
with the following contents:Run
ec2-metadata-mock -c overrides.json
.The program exits with an error message about the type of the
marketplaceProductCodes
field.Expected outcome The application starts up and serves the supplied instance identity document.
Application Logs
Environment