A Lambda backed custom resource for CloudFormation that provides information about an RDS instance or cluster
This custom resource provides information about an AWS RDS instance or cluster.
It might be useful in situations where your RDS resource is outside of a CloudFormation stack where it would be helpful to have that information without the need to enter several parameters. It might also be helpful in situations where you need additional information about an RDS resource that the return values for AWS::RDS::DBInstance and AWS::RDS::DBCluster do not include.
This custom resource can be installed on your AWS account by deploying the CloudFormation template at cloud-formation/cloud-formation.yml, and then updating the Lambda function it creates with the code from python/index.py
The Lambda function's ARN, which is needed for use as a service token when
using this custom resource in your CloudFormation templates, will be exported
as an output with the name ${AWS::StackName}-FunctionArn
. This service
token will also be stored in
Systems Manager Parameter Store
at
/cloud-formation/service-tokens/rds-properties
Once installed, you can test the custom resource by using the CloudFormation template at cloud-formation/example-cloud-formation.yml, which will create a stack with outputs from the custom resource.
The syntax for declaring this resource:
RdsProperties:
Type: "AWS::CloudFormation::CustomResource"
Version: "1.0"
Properties:
ServiceToken: LAMDA_FUNCTION_ARN
DBInstanceIdentifier: DB_INSTANCE_IDENTIFIER
DBClusterIdentifier: DB_CLUSTER_IDENTIFIER,
Type: String
Required: Yes
Type: String
Required: Conditional. Exactly one of either DBInstanceIdentifier or DBClusterIdentifier are required
Type: String
Required: Conditional. Exactly one of either DBInstanceIdentifier or DBClusterIdentifier are required
When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the DBInstanceIdentifier property
Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes.
The ARN of the RDS resource.
The AWS Region-unique, immutable identifier for the RDS resource. For instances, this will be the DbiResourceId. For clusters, this will be the DbClusterResourceId.
The name of the database that was created with the RDS resource
The endpoint address of the RDS resource
The endpoint port of the RDS resource
The reader endpoint for the RDS resource. For instances, this will always be the same as Endpoint.Address
The engine of the RDS resource
The engine version of the RDS resource
True if mapping of AWS Identity and Access Management (IAM) accounts to database accounts is enabled, and otherwise false.
The master username for the RDS instance