Home > other >  How to trigger an any aws resource based on creation of another aws resource?
How to trigger an any aws resource based on creation of another aws resource?

Time:02-02

I am using cloudformation template to build a dynamo db ( see below), once the stack builds successfully, I would like to alert/notify/trigger another aws resource, like a lambda function or a step function or a aws data pipeline to start such that I can start populating the dynamo. what is the best way to trigger another process or aws resource once cloudformation stack creation is successful ?

AWSTemplateFormatVersion: 2010-09-09
Description: AWS CloudFormation Template To Create a DynamoDB

Parameters:
  HashKeyElementName:
    Type: String
    Default: Id
    Description: Hash Key Name
  HashKeyElementType:
    Type: String
    Default: S
    Description: Hash Key Type
Resources:
  Table:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: MyTable
      AttributeDefinitions:
        - 
          AttributeName: !Ref HashKeyElementName
          AttributeType: !Ref HashKeyElementType
      KeySchema:
        - 
          AttributeName: !Ref HashKeyElementName
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 5
        WriteCapacityUnits: 5 
Outputs:
  MyTable:
    Description: Table Created using this template.
    Value: !Ref Table

CodePudding user response:

You can setup SNS topic and a lambda function to get events from stack creation. An example of how to do it is given in AWS docs:

You would have to adapt the example and the lambda to suit your needs.

  •  Tags:  
  • Related