Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Fn::Select + Fn::GetAzs Issues #204

Closed
rhyselsmore opened this issue May 14, 2019 · 0 comments
Closed

Fn::Select + Fn::GetAzs Issues #204

rhyselsmore opened this issue May 14, 2019 · 0 comments

Comments

@rhyselsmore
Copy link

rhyselsmore commented May 14, 2019

Hi team,

First of all, thank you for a great package. I'm a big fan.

I've come across a bit of weird behaviour in terms of the typing of cfn.Select, and when you try and pass other functions that return an array to it.

My use case is creating a subnet based on the availability zones available to me, as per the documentation here.

Within those docs, you will see mention of the YAML snippet below:

mySubnet: 
  Type: "AWS::EC2::Subnet"
  Properties: 
    VpcId: 
      !Ref VPC
    CidrBlock: 10.0.0.0/24
    AvailabilityZone: 
      Fn::Select: 
        - 0
        - Fn::GetAZs: ""

My problem is that cloudformation.Select is typed to accept an array of strings as the second argument, when in fact the cloudformation.GetAzs already returns an array.

I've tried:

AvailabilityZone: cfn.Select(0, []string{
	cfn.GetAZs(""),
}),

and it does not work. It results in this template:

AWSTemplateFormatVersion: "2010-09-09"
Resources:
  Subnet1:
    Properties:
      AvailabilityZone:
        Fn::Select:
        - "0"
        - - Fn::GetAZs: ""
      VpcId:
        Ref: VPC
    Type: AWS::EC2::Subnet
  VPC:
    Properties:
      CidrBlock: 10.192.0.0/22
    Type: AWS::EC2::VPC

My initial thoughts is that there might be the need for cloudformation.Select to accept an interface. If it receives an array of strings, it uses these as the array of possible choices. If it receives a single string, it assumes that this is a CloudFormation function?

I haven't fully thought this through, but at the moment I am a bit stuck and need to hard code availability zones.

Thanks for your time, please let me know if I can elaborate or help in any way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants