List of RDS instances in cloudformation template as parameters

0

Hello ,

How can I get dynamically list of RDS instances IDs to use it as parameter in cloudformation template ?

Something like below but generated dynamically :

 Parameters:
  RDSInstanceIDParameter:
    Type: String
    Default: rds-a1
    AllowedValues:
      - !Select [ "1", [ "rds-a1", "rds-a2", "rds-a3", "rds-a4" ] ]
      - !Select [ "2", [ "rds-a1", "rds-a2", "rds-a3", "rds-a4" ] ]
      - !Select [ "3", [ "rds-a1", "rds-a2", "rds-a3", "rds-a4" ] ]
    Description: Enter logical name ID of RDS which You want to integrate with EFS .

How can I get list of RDS ids etc. " [ "rds-a1", "rds-a2", "rds-a3", "rds-a4" ] ]"

It is possible to use some inline javascript/python code here ? What are my options ?

1 Answer
0

Hello, I think this can help you in obtaining the dynamic list.

  • Create an SSM parameter (e.g., /myapp/rds_instance_ids) of type String to store the list of RDS instance IDs.
  • Develop a Lambda function with permissions to call the ssm:GetParametersByPath API.
  • Write code in the Lambda function to fetch the list of RDS instance IDs and update the SSM parameter.
  • Configure a CloudWatch Event rule to trigger the Lambda function at regular intervals (e.g., every hour).
  • Define a parameter in the CloudFormation template (e.g., RDSInstanceIDParameter) with AllowedValues referencing the SSM parameter created in step 1.

CloudFormation template will dynamically fetch the latest list of RDS instance IDs from the SSM parameter upon deploy of the stack. Hope This Helps

profile picture
EXPERT
answered 23 days ago
profile picture
EXPERT
reviewed 23 days ago
  • Grazie mille for Your effort and response . But I am afraid, what I want is not possible .

    I have tried following but it seems , that reference is not interpreted (When I used it for tag it worked, see picture below).

    Parameters:
      RDSInstanceIDParameter:
        Type: String
        Default: ec-a1
        AllowedValues:
          - ec-a1
          - "{{resolve:ssm:RDS_LIST_MKI:1}}"
    

    Result: Enter image description here

    I have also tried to use 'Fn::Transform' with macro/lambda function to modify content , but the Stack interpreter seems don't like it. For modifying resources on the fly it worked fine.

    Enter image description here

    Error

    Enter image description here

    If you have any other ideas, I'm curious about them.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions