Create DBSubnetGroup SubnetIds from ASW::EC2::Subnet:Id in CloudFormation

0

I am trying to create an Aurora MySQL RDS using CloudFormation. The code below is just a snippet of what it is doing. The issue I am having is that the SubnetIds for the DBSubnetGroup is not accepting what is being passed. It either errors out with receiving jsonarray instead of string. Or receiving jsonobject instead of jsonarray. Has anyone worked on this?

AWSTemplateFormatVersion: "2010-09-09"
Metadata:
  AWS::CloudFormation::Interface: 
      ParameterGroups: 
      - 
        Label: 
          default: "Network Configuration"
        Parameters:
          - MainRegion
          - ClusterPrefix
          - VPCName
          - VPCSecurityGroupIds
          - SelectedSubnetIds

Parameters:

  MainRegion:
    Type: String
    Default: us-west-2
    AllowedValues:
      - us-east-1
      - us-east-2
      - us-west-1
      - us-west-2      
    Description: Select the main region of choice.

  ClusterPrefix:
    Description: Enter (in lowercase) the cluster prefix that will be added to the begining of the RDS resource
    Type: String
    Default: abc

  VPCName:
    Description: Select the VPC for the RDS Aurora MySQL
    Type: AWS::EC2::VPC::Id

  VPCSecurityGroupIds:
    Description: Select the VPC Security Group
    Type: "List<AWS::EC2::SecurityGroup::Id>"

  SelectedSubnetIds:
    Description: Select the subnets
    Type: "List<AWS::EC2::Subnet::Id>"


Resources:

    RDSDBSubnetGroup:
        Type: "AWS::RDS::DBSubnetGroup"
        Properties:
            DBSubnetGroupDescription: "Subnet Group for Name Global DB"
            DBSubnetGroupName: "${ClusterPrefix}-name-db-sg"
            SubnetIds: 
               - !Ref SelectedSubnetIds
              #[ SelectedSubnetIds ]
              #'!ForEach::SelectValue':
              #  - SelectedSubnet
              #  - !Ref SelectedSubnetIds
                #- SelectedSubnet
                #- !Ref 'Fn::Sub': '${SelectedSubnet}'
                #- !Join [ ",", [ SelectedSubnet ] ]
               # - Fn::ToJsonString SelectedSubnet
                #- ListOutput: true

질문됨 3달 전218회 조회
1개 답변
1
수락된 답변

Have you tried:

    RDSDBSubnetGroup:
        Type: "AWS::RDS::DBSubnetGroup"
        Properties:
            DBSubnetGroupDescription: "Subnet Group for Name Global DB"
            DBSubnetGroupName: "${ClusterPrefix}-name-db-sg"
            SubnetIds: !Ref SelectedSubnetIds

I suspect the "-" is saying it is an element of an array instead of the just the array.

profile pictureAWS
전문가
kentrad
답변함 3달 전
  • I've tried many ways and I believe that was one of them. However, it does produce a different error.

    Properties validation failed for resource RDSDBSubnetGroup with message: #/DBSubnetGroupName: failed validation constraint for keyword [pattern]

  • Thank you very much. Obviously, I never tried that one because after that the naming convention was simple. Thank you again kentrad

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠