Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion data/data/aws/vpc/common.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
data "aws_region" "current" {}

// Fetch a list of available AZs
data "aws_availability_zones" "azs" {}
data "aws_availability_zones" "azs" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I'm wrong, but with #1121 the available check in go will make sure that the masterAZs chosen were available and az_to_<public/private>subnet maps will make sure we only create machines in AZs chosen by installer

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe I'm wrong, but with #1121 the available check in go...

Yup, the Terraform part of this is code that is hopefully going away soon. But we want the Go part of this long-term, and the Terraform code is still there now, so I think we might as well fix it too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well technically terraform should use the AZs given by the installer ie if the AZ goes out of service between asset generation and terraform call... it would be better if we fail with error that AZ is out of service rather than the AZ not found in the az_to_<public/private>subnet maps.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well technically terraform should use the AZs given by the installer...

Agreed.

... ie if the AZ goes out of service between asset generation and terraform call...

I think using Go-provided zones means we can drop this data "aws_availability_zones" section altogether. Guarding against a zone going down is always going to be racy up through actually creating resources in the zone, so I'd rather save a few lines and the mental overhead and just have Terraform assume Go has already done any required validation and blindly consume what it was given.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think using Go-provided zones means we can drop this data "aws_availability_zones" section altogether. Guarding against a zone going down is always going to be racy up through actually creating resources in the zone, so I'd rather save a few lines and the mental overhead and just have Terraform assume Go has already done any required validation and blindly consume what it was given.

I can get behind that change. :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can get behind that change. :)

Did you want me to pick that up in this PR? Or submit it as a follow-up once this lands?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think using Go-provided zones means we can drop this data "aws_availability_zones" section altogether. Guarding against a zone going down is always going to be racy up through actually creating resources in the zone, so I'd rather save a few lines and the mental overhead and just have Terraform assume Go has already done any required validation and blindly consume what it was given.

I can get behind that change. :)

But that would need some changes esp https://jira.coreos.com/browse/CORS-902, that will push this PR to 4.1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can get behind that change. :)

Did you want me to pick that up in this PR? Or submit it as a follow-up once this lands?

follow up is fine.

state = "available"
}

// Only reference data sources which are gauranteed to exist at any time (above) in this locals{} block
locals {
Expand Down
15 changes: 10 additions & 5 deletions pkg/asset/machines/aws/zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ func ec2Client(region string) (*ec2.EC2, error) {
}

func fetchAvailabilityZones(client *ec2.EC2, region string) ([]string, error) {
zoneFilter := &ec2.Filter{
Name: aws.String("region-name"),
Values: []*string{aws.String(region)},
}
req := &ec2.DescribeAvailabilityZonesInput{
Filters: []*ec2.Filter{zoneFilter},
Filters: []*ec2.Filter{
{
Name: aws.String("region-name"),
Values: []*string{aws.String(region)},
},
{
Name: aws.String("state"),
Values: []*string{aws.String("available")},
},
},
}
resp, err := client.DescribeAvailabilityZones(req)
if err != nil {
Expand Down