Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marketplaceProductCodes field is typed as a string instead of a list of strings #179

Closed
okofish opened this issue Jun 23, 2022 · 1 comment · Fixed by aws/homebrew-tap#359 or aws/eks-charts#782
Labels
bug Something isn't working

Comments

@okofish
Copy link

okofish commented Jun 23, 2022

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

  1. Create a file overrides.json with the following contents:
{
	"dynamic": {
		"values": {
			"instance-identity-document": {
				"accountId": "123456789012",
				"architecture": "x86_64",
				"availabilityZone": "us-east-1a",
				"billingProducts": null,
				"devpayProductCodes": null,
				"marketplaceProductCodes": [
					"4i20ezfza3p7xx2kt2g8weu2u"
				],
				"imageId": "ami-02f471c4f805553d3",
				"instanceId": "i-048bcb15d2686eec7",
				"instanceType": "t2.nano",
				"kernelId": null,
				"pendingTime": "2022-06-23T06:21:55Z",
				"privateIp": "172.31.85.190",
				"ramdiskId": null,
				"region": "us-east-1",
				"version": "2017-09-30"
			}
		}
	}
}
  1. 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

$ 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

Environment

  • AEMM Version: v1.10.1
  • OS/Arch: macOS 11.6.2
  • Installation method: Homebrew
@okofish okofish added the bug Something isn't working label Jun 23, 2022
@brycahta
Copy link
Contributor

Appreciate the call out; fix on the way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants