soto-project / soto

Swift SDK for AWS that works on Linux, macOS and iOS
https://soto.codes
Apache License 2.0
878 stars 83 forks source link

KMS throws fatal runtime error (Fatal error: Dictionary literal contains duplicate keys) #644

Closed zaggo closed 1 year ago

zaggo commented 1 year ago

Describe the bug When initializing KMS, the app stops with a fatal error: Fatal error: Dictionary literal contains duplicate keys at KMS_API.swift:58

The source at this location looks like this:

            serviceEndpoints: [
                "ProdFips": "kms-fips.eu-central-2.amazonaws.com",
                "ProdFips": "kms-fips.us-gov-west-1.amazonaws.com",
                "ProdFips": "kms-fips.us-iso-east-1.c2s.ic.gov",
                "ProdFips": "kms-fips.us-isob-east-1.sc2s.sgov.gov",
                "af-south-1-fips": "kms-fips.af-south-1.amazonaws.com",
                "ap-east-1-fips": "kms-fips.ap-east-1.amazonaws.com",

The 4 instances of ProdFips as keys seem to be the problem…

To Reproduce Steps to reproduce the behavior:

  1. add .product(name: "SotoKMS", package: "soto") dependency to a project
  2. initialize KMS, e.g. like this: let kms = SotoKMS.KMS(client: awsClient, region: region)
  3. run the code (especially the KMS initializer)
  4. -> Fatal error: Dictionary literal contains duplicate keys (see above)

Expected behavior The KMS initializer is executed without a fatal error.

Setup (please complete the following information):

adam-fowler commented 1 year ago

Ah that's frustrating that isn't caught at compilation time. This is being caused by a clash of endpoint names across different AWS partitions. I don't even think the ProdFips endpoints are ever used. I'll see if I can fix the code generator to not output these.