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 个月前128 查看次数
1 回答
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
专家
已回答 1 个月前
profile picture
专家
已审核 1 个月前
  • 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.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则