AWSTemplateFormatVersion: '2010-09-09' Description: Hello World Lambda via CloudFormation Resources: HelloLambdaRole: Type: AWS::IAM::Role Properties: RoleName: hello-world-lambda-role-cft AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: lambda.amazonaws.com Action: sts:AssumeRole ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole HelloLambdaFunction: Type: AWS::Lambda::Function Properties: FunctionName: hello-world-lambda-cft Runtime: python3.12 Handler: index.lambda_handler Role: !GetAtt HelloLambdaRole.Arn Timeout: 10 Code: ZipFile: | def lambda_handler(event, context): return { "statusCode": 200, "body": "Hello from Lambda via CloudFormation!" } Outputs: LambdaName: Value: !Ref HelloLambdaFunction