Articles → AWS → DependsOn Attribute In AWS CloudFormation

DependsOn Attribute In AWS CloudFormation






Purpose





Create A YAML File




AWSTemplateFormatVersion: "2010-09-09"
Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-depends-on-example-bucket-gyansangrah

  MyLambdaFunction:
    Type: AWS::Lambda::Function
    DependsOn: MyS3Bucket
    Properties:
      FunctionName: MyExampleLambda
      Handler: index.handler
      Role: arn:aws:iam::[account_id]:role/Lambdarole
      Runtime: python3.9
      Code:
        ZipFile: |
          def handler(event, context):
              print("Lambda executed")





Create A Stack




Picture showing the S3 bucket created followed by the lambda function



Output


Picture showing the S3 bucket created using the cloudformation


Picture showing the lambda function created using the cloudformation



Posted By  -  Karan Gupta
 
Posted On  -  Monday, February 24, 2025

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250