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 個月前檢視次數 132 次
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.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南