JSFiddle - React, Tailwind, and code Playground
JavaScript
// .... the rds server init here
const rdsDataServer = new aws.rds.Instance("db-aja-uat-us1-db", {
// ... settings goes here
}
);
// as this code should only be run on the deploy mode, we need to make sure that we are not in preview mode
const isPreview = pulumi.runtime.isDryRun();
if (!isPreview) {
rdsDataServer.endpoint.apply(rdsDataServerEndpoint => {
rdsDataServer.port.apply(rdsDataServerPort => {
pulumi.log.info("database endpoint is : " + rdsDataServerEndpoint + ":" + rdsDataServerPort)
// first, get the rds arn name
rdsDataServer.arn.apply(rdsArnName => {
// set the log
pulumi.log.info("rds arn name is: " + rdsArnName)
// Use getResource and filter
const secretValueOutput = aws.resourcegroupstaggingapi.getResourcesOutput({
tagFilters: [{
key: "aws:rds:primaryDBInstanceArn",
values: [
rdsArnName
],
}],
})
// now, check for the secret value
secretValueOutput.apply(secretValue => {
// get the resources list
const getResourcesResourceTagMappingLists = secretValue.resourceTagMappingLists
if (!getResourcesResourceTagMappingLists || getResourcesResourceTagMappingLists.length == 0) {
// we are not able to find the secret resource value
// 1: may bew we do not have access
// 2: may be amazon has changed the pattern of that
throw new Error("unable to find the secret manager key which is associated to RDS")
} else {
...