Skip to content

Commit

Permalink
fix(sdk): cherrypick default az for wing app (#4151)
Browse files Browse the repository at this point in the history
Currently, when a new Wing app is created for AWS targets, it's left up to AWS to choose a random AZ in which to deploy the private and public subnets. With this change, we tell AWS that we always want to deploy to the first AZ of whatever region specified by the user, which is generally the one that has the broadest range of services available.

Closes #4126

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
garysassano authored Sep 19, 2023
1 parent b71cae1 commit 3db16c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/wingsdk/src/target-tf-aws/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class App extends CdktfApp {
const publicSubnet = new Subnet(this, "PublicSubnet", {
vpcId: this._vpc.id,
cidrBlock: "10.0.0.0/24", // 10.0.0.0 - 10.0.0.255
availabilityZone: `${this.region}a`,
tags: {
Name: `${identifier}-public-subnet-1`,
},
Expand All @@ -202,6 +203,7 @@ export class App extends CdktfApp {
const privateSubnet = new Subnet(this, "PrivateSubnet", {
vpcId: this._vpc.id,
cidrBlock: "10.0.4.0/22", // 10.0.4.0 - 10.0.7.255
availabilityZone: `${this.region}a`,
tags: {
Name: `${identifier}-private-subnet-1`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

exports[`When creating a Redis resource > should create an elasticache cluster and required vpc networking resources 1`] = `
{
"data": {
"aws_region": {
"Region": {},
},
},
"output": {
"WING_TEST_RUNNER_FUNCTION_ARNS": {
"value": "[]",
Expand Down Expand Up @@ -149,13 +154,15 @@ exports[`When creating a Redis resource > should create an elasticache cluster a
},
"aws_subnet": {
"PrivateSubnet": {
"availability_zone": "\${data.aws_region.Region.name}a",
"cidr_block": "10.0.4.0/22",
"tags": {
"Name": "Default-c82bf964-private-subnet-1",
},
"vpc_id": "\${aws_vpc.VPC.id}",
},
"PublicSubnet": {
"availability_zone": "\${data.aws_region.Region.name}a",
"cidr_block": "10.0.0.0/24",
"tags": {
"Name": "Default-c82bf964-public-subnet-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ module.exports = function({ $queue, $r, $r2, $util_Util }) {
}
}
},
"data": {
"aws_region": {
"Region": {
"//": {
"metadata": {
"path": "root/Default/Region",
"uniqueId": "Region"
}
}
}
}
},
"output": {
"WING_TEST_RUNNER_FUNCTION_ARNS": {
"value": "[]"
Expand Down Expand Up @@ -476,6 +488,7 @@ module.exports = function({ $queue, $r, $r2, $util_Util }) {
"uniqueId": "PrivateSubnet"
}
},
"availability_zone": "${data.aws_region.Region.name}a",
"cidr_block": "10.0.4.0/22",
"tags": {
"Name": "Default-c82bf964-private-subnet-1"
Expand All @@ -489,6 +502,7 @@ module.exports = function({ $queue, $r, $r2, $util_Util }) {
"uniqueId": "PublicSubnet"
}
},
"availability_zone": "${data.aws_region.Region.name}a",
"cidr_block": "10.0.0.0/24",
"tags": {
"Name": "Default-c82bf964-public-subnet-1"
Expand Down

0 comments on commit 3db16c1

Please sign in to comment.