Skip to content

Commit

Permalink
Revert "Exclude the 'd' availablity zone from aws"
Browse files Browse the repository at this point in the history
This reverts commit b91a39b.
  • Loading branch information
Chris Dutra authored and notrepo05 committed Jun 11, 2019
1 parent 414e1e5 commit cd8279f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 51 deletions.
2 changes: 1 addition & 1 deletion aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c Client) RetrieveDNS(url string) string {
return parentDomain
}

// Return the AWS Availability Zones for a given region in sorted order.
// Return the AWS Availability Zones for a given region.
func (c Client) RetrieveAZs(region string) ([]string, error) {
output, err := c.ec2Client.DescribeAvailabilityZones(&awsec2.DescribeAvailabilityZonesInput{
Filters: []*awsec2.Filter{{
Expand Down
6 changes: 0 additions & 6 deletions cloudconfig/aws/ops_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ type lbCloudProperties struct {

var marshal func(interface{}) ([]byte, error) = yaml.Marshal

const azLimit = 3

func NewOpsGenerator(terraformManager terraformManager, availabilityZones availabilityZones) OpsGenerator {
return OpsGenerator{
terraformManager: terraformManager,
Expand Down Expand Up @@ -222,10 +220,6 @@ func (o OpsGenerator) generateOps(state storage.State) ([]op, error) {
return []op{}, fmt.Errorf("Retrieve availability zones: %s", err)
}

if len(azs) > azLimit {
azs = azs[:len(azs)-1]
}

for i := range azs {
azOp := createOp("replace", "/azs/-", az{
Name: fmt.Sprintf("z%d", i+1),
Expand Down
10 changes: 0 additions & 10 deletions cloudconfig/aws/ops_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,6 @@ iso_az_subnet_id_mapping:

Expect(opsYAML).To(MatchYAML(expectedOpsYAML))
})

Context("when more than 3 azs are available in the region", func() {
It("returns an ops file that only includes the first 3 azs", func() {
availabilityZones.RetrieveAZsCall.Returns.AZs = []string{"us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d"}
opsYAML, err := opsGenerator.Generate(incomingState)
Expect(err).NotTo(HaveOccurred())

Expect(opsYAML).To(MatchYAML(expectedOpsYAML))
})
})
})

Context("when there are cf lbs", func() {
Expand Down
5 changes: 0 additions & 5 deletions terraform/aws/input_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type awsClient interface {
}

const terraformNameCharLimit = 18
const azLimit = 3

func NewInputGenerator(awsClient awsClient) InputGenerator {
return InputGenerator{
Expand All @@ -32,10 +31,6 @@ func (i InputGenerator) Generate(state storage.State) (map[string]interface{}, e
return map[string]interface{}{}, err
}

if len(azs) > azLimit {
azs = azs[:len(azs)-1]
}

shortEnvID := state.EnvID
if len(shortEnvID) > terraformNameCharLimit {
sha1 := fmt.Sprintf("%x", sha1.Sum([]byte(state.EnvID)))
Expand Down
26 changes: 0 additions & 26 deletions terraform/aws/input_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,6 @@ var _ = Describe("InputGenerator", func() {
})
})

Context("when more than 3 azs are available in the region", func() {
It("uses the first 3 azs for availability_zones", func() {
awsClient.RetrieveAZsCall.Returns.AZs = []string{"z1", "z2", "z3", "z4"}

inputs, err := inputGenerator.Generate(storage.State{
EnvID: "some-env-id",
AWS: storage.AWS{
AccessKeyID: "some-access-key-id",
SecretAccessKey: "some-secret-access-key",
Region: "some-region",
},
LB: storage.LB{
Type: "concourse",
},
})
Expect(err).NotTo(HaveOccurred())

Expect(inputs).To(Equal(map[string]interface{}{
"env_id": "some-env-id",
"short_env_id": "some-env-id",
"region": "some-region",
"availability_zones": []string{"z1", "z2", "z3"},
}))
})
})

It("receives BBL state and returns a map of terraform variables", func() {
inputs, err := inputGenerator.Generate(storage.State{
EnvID: "some-env-id",
Expand Down
5 changes: 2 additions & 3 deletions terraform/aws/templates/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ resource "aws_security_group_rule" "bosh_internal_security_rule_udp" {
}

resource "aws_subnet" "bosh_subnet" {
vpc_id = "${local.vpc_id}"
cidr_block = "${cidrsubnet(var.vpc_cidr, 8, 0)}"
availability_zone = "${element(var.availability_zones, 0)}"
vpc_id = "${local.vpc_id}"
cidr_block = "${cidrsubnet(var.vpc_cidr, 8, 0)}"

tags {
Name = "${var.env_id}-bosh-subnet"
Expand Down

0 comments on commit cd8279f

Please sign in to comment.