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

feat: (IAC-367) Allow Ability To Specify Which Availability Zones the Subnets Get Created In #236

Closed
wants to merge 3 commits into from

Conversation

jarpat
Copy link
Contributor

@jarpat jarpat commented Oct 5, 2023

Changes

Allows users the ability to specify which AZs that the subnet gets created in with the new subnet_azs variable.

Similar to the existing subnets the map lets to set the name of the subnet along with zones will be used during creation

subnet_azs = {
  "private"  : ["us-east-2c", "us-east-2b"],
  "public"   : ["us-east-2a", "us-east-2b"],
  "database" : ["us-east-2a", "us-east-2b"]
}

So if your defined subnets as so in your .tfvars

{
  "private" : ["192.168.0.0/18", "192.168.64.0/18"],
  "public" : ["192.168.129.0/25", "192.168.129.128/25"],
  "database" : ["192.168.128.0/25", "192.168.128.128/25"]
}

for "private" : ["192.168.0.0/18", "192.168.64.0/18"], the first subnet will be created in us-east-2c and the second in us-east-2b

This variable is entirely optional, and if not defined the code will perform a lookup to populate the zones just like the behavior in viya4-iac-aws:7.2.1 and prior. If entire keys are not defined, the lookup will be used to populate those. Also, If not enough zones are defined in the subnet_azs in comparison to the subnets map a the zone lookup will be done to make up the difference. (behavior removed)

Test

WIP

@jarpat jarpat self-assigned this Oct 5, 2023
@jarpat jarpat added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 5, 2023
Copy link
Member

@thpang thpang left a comment

Choose a reason for hiding this comment

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

Need to review the need to add or change what the customer is providing.

locals.tf Outdated
Comment on lines 38 to 61
public_subnet_azs = (
can(var.subnet_azs["public"]) ?
(length(var.subnet_azs["public"]) >= length(lookup(var.subnets, "public", [])) ?
var.subnet_azs["public"]
: distinct(concat(var.subnet_azs["public"], data.aws_availability_zones.available.names)))
: data.aws_availability_zones.available.names
)

private_subnet_azs = (
can(var.subnet_azs["private"]) ?
(length(var.subnet_azs["private"]) >= length(lookup(var.subnets, "private", [])) ?
var.subnet_azs["private"]
: distinct(concat(var.subnet_azs["private"], data.aws_availability_zones.available.names)))
: data.aws_availability_zones.available.names
)

database_subnet_azs = (
can(var.subnet_azs["database"]) ?
(length(var.subnet_azs["database"]) >= length(lookup(var.subnets, "database", [])) ?
var.subnet_azs["database"]
: distinct(concat(var.subnet_azs["database"], data.aws_availability_zones.available.names)))
: data.aws_availability_zones.available.names
)

Copy link
Member

@thpang thpang Oct 5, 2023

Choose a reason for hiding this comment

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

The code now takes what the customer provided an augments that value, i.e. its not what the customer provided, its a very well educated guess and provides what's needed, but it simply covers up the user error in that they did not provide the correct number of items for this element. Need a discussion on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, it may be better not to correct or append to the user input and let it fail, the user should correct any mistakes made.
This should be a quick update to the local.tf + doc , I'll make the change and test it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the behavior, no longer correcting user input and will let it fail instead. The user should be responsible for correct input. Docs and locals.tf changed, performing tests.

@jarpat
Copy link
Contributor Author

jarpat commented Nov 2, 2023

Closing this PR, need to rebase and rework this slightly after the most recent changes from IAC-1174.

@jarpat jarpat closed this Nov 2, 2023
@jarpat jarpat deleted the IAC-367 branch November 2, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants