Skip to content

Parsing yaml to get one account ID for a specific use-case is difficult #44

@nitrocode

Description

@nitrocode

Problem

For example, segmentio has 2 sources and 2 account ids

- name: 'SegmentIO'
source: ['https://segment.com/docs/destinations/amazon-s3/', 'https://segment.com/docs/destinations/amazon-kinesis/']
accounts: ['107630771604', '595280932656']

I assume each account id comes from its respective source.

If that's the case, I'd have to figure out which source relates to my use-case, and then get the respective account id. This is a little tricky the way the yaml is structured.

Proposal

What do you folks think about this format instead?

- name: 'SegmentIO'
  purpose:
    s3:
      source: 'https://segment.com/docs/destinations/amazon-s3/'
      account: '107630771604'
    kinesis:
      source: 'https://segment.com/docs/destinations/amazon-kinesis/'
      account: '595280932656'

or even with a full map, no list. This has an additional benefit of having its vendor names alphabetized.

accounts:
  segmentio:
    name: 'SegmentIO'
    purpose:
      s3:
        source: 'https://segment.com/docs/destinations/amazon-s3/'
        account: '107630771604'
      kinesis:
        source: 'https://segment.com/docs/destinations/amazon-kinesis/'
        account: '595280932656'

Now I can do something like this

>>> external_accounts["segmentio"]["purpose"]["s3"]["account"]
'107630771604'

Notes

  • I noticed is that source is sometimes a static URL and other times it's an array. The above proposal can fix this issue too.
    - name: 'Cloudhealth'
    source: 'https://github.com/mozilla/security/blob/master/operations/cloudformation-templates/cloudhealth_iam_role.json'
    accounts: ['454464851268']
    - name: 'SegmentIO'
    source: ['https://segment.com/docs/destinations/amazon-s3/', 'https://segment.com/docs/destinations/amazon-kinesis/']
    accounts: ['107630771604', '595280932656']
  • Sometimes a source is missing
    - name: 'Rockset'
    accounts: ['216690786812']
    - name: 'CloudHiro'
  • Sometimes more than one account ID is in a vendor with ONLY a single source which is OK in the above proposal too
    - name: 'Qualys Cloud View'
    source: 'https://qualysguard.qualys.com/qwebhelp/fo_portal/scans/ec2_connector.htm'
    accounts: ['080595016317', '205767712438']
  • There are deprecations in titles
    - name: '[Deprecated] AWS Log delivery Service'
    source: 'https://forums.aws.amazon.com/thread.jspa?messageID=629256'
    accounts: ['858827067514']
    • These can instead be in the yaml. Preferably not a deprecated: true because that name would be set in the "negative" instead of "positive"
      # simple enabled/disabled, if disabled, assume deprecated
      enabled: false
      # if it's current or not, if not, assume deprecated
      current: false
      # if this key is set, assume deprecated
      deprecated_date: 2025-12-31
      # or maybe a last updated_date and then all deprecated accounts can be moved
      # to a separate file such as accounts_deprecated.yaml
      updated_date: 2024-12-31

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions