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

support defining AZs through account mapping #6

Merged
merged 2 commits into from
May 6, 2021

Conversation

Guslington
Copy link
Member

@Guslington Guslington commented Apr 22, 2021

Selecting Availability Zones

By default the vpc-v2 component will automatically select the AZs. This is achieved by looping over the max_availability_zones count and using the Fn::GetAZs Cloudformation function to select the AZ id.

max_availability_zones.times |az|
  selected_az = FnSelect(az, FnGetAZs(Ref('AWS::Region')))
end

However if you wish to define which as AZs you want to use you can by configuring a map per AWS account with the AZs you wish to use.
NOTE: the total count of AZ's defined in the map for each account has to be the same value as max_availability_zones.

To configure your AZ settings, set az_mapping to true

az_mapping: true

Then configure a map in the following structure to define your AZs

Accounts:
  '000000000000': # AWS Account Id
    AZs: '3,5,0' # Comma delimited list of numerical values that maps to the Availability Zone for that account

the numerical values will map to the Availability Zone retuned from the Fn::GetAZs function in the AWS account. For example in us-east-1 returns

[ "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f" ]

therefore the mapping AZs: '3,5,0' will use AZs [ "us-east-1d", "us-east-1f", "us-east-1a" ]

the new function to retrieve the AZ becomes

max_availability_zones.times |az|
  selected_az = FnSelect(FnSelect(az, FnSplit(',', FnFindInMap('Accounts', Ref('AWS::AccountId'), 'AZs'))), FnGetAZs(Ref('AWS::Region')))
end

@Guslington Guslington requested a review from aaronwalker April 22, 2021 01:22
Copy link
Member

@aaronwalker aaronwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.... just a minor documentation improvement

README.md Outdated Show resolved Hide resolved
@Guslington Guslington requested a review from aaronwalker May 5, 2021 00:21
@Guslington Guslington merged commit f522860 into master May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants