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

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

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ