0

I am using AWS Cloudformation to create an application that deploys some instances inside a cluster with an Autoscaling group. I'm deploying it at us-east-1

The thing is that yesterday we changed to Summertime, and my script stopped working, giving me a very weird error, because I had run the same script on Friday and it was working perfectly.

After some debugging, I found the culprit and it seems to be the intrinsic function Fn::GetAZs.

I was specifying my availability zones and subnets for the Autoscaling group and the error was:

The availability zones of the specified subnets and the Auto Scaling group do not match

After that I changed my script. Instead of having the following format:

AvailabilityZones:
     - Fn::Select:
       - '0'
       - Fn::GetAZs:
           Ref: AWS::Region
     - Fn::Select:
       - '1'
       - Fn::GetAZs:
           Ref: AWS::Region
     - Fn::Select:
       - '2'
       - Fn::GetAZs:
           Ref: AWS::Region

I used this format

AvailabilityZones:
    - us-east-1a
    - us-east-1b
    - us-east-1c

And it worked, but of course I can't have hardcoded values like that. This lead me to think that after the timezone changed it started to fail. My current location is Belo Horizonte - Brazil

Is anyone facing the same issue ? Does it make sense ?

Thanks.

Juan Rivillas
  • 897
  • 2
  • 9
  • 23
  • Are you deploying to Virginia or São Paulo? I don't think your physical location makes any difference, since none of the processing is performed on the client side. – tyron Nov 05 '18 at 13:39
  • 1
    Be aware that for VPC, the Fn::GetAZs function returns **only** AZs that have a default subnet (unless none of the AZs has a default subnet, in which case **all** AZs are returned). – jarmod Nov 05 '18 at 14:21
  • I'm deploying it at us-east-1 – Juan Rivillas Nov 05 '18 at 16:08
  • On the surface, it seems that the time change is coincidental and not related to the problem. Sure - it's possible, but not likely. Have you seen [this question](https://stackoverflow.com/q/44004118/634824) already? Is that the same as what you are dealing with? – Matt Johnson-Pint Nov 05 '18 at 18:19
  • @jarmod thanks, I was deploying extra subnet as changeset to pick a new AZ dynamically and ran into the error. Deleting previous elements and re-creation too ran into same error `Template error: Fn::Select cannot select nonexistent value at index 1` ``` Fn::Select: - '1' - Fn::GetAZs: Ref: AWS::Region ``` – prasun Jul 15 '21 at 07:22

1 Answers1

0

Fn::GetAZs returns availability zones in which you have default subnets in your default VPC. Maybe you deleted such subnects.

You have two options:

  • recreate default VPC with default subnets;
  • remove default VPC entirely.

Sidenote: Fn::GetAZs works in current region if not specified, so you don't need to use

Fn::GetAZs:
    Ref: AWS::Region

You can simplify it into:

Fn::GetAZs: ""
Rafał Wrzeszcz
  • 1,996
  • 4
  • 23
  • 45