Question: # Lambda Function # TODO 6 : Create a Lambda function using the Lambda deployment package stored in S 3 . # - Set up
# Lambda Function
# TODO : Create a Lambda function using the Lambda deployment package stored in S
# Set up the Lambda function in PrivateSubnet to restrict internet access. Properties : VpcConfig SubnetIds
# Use the default Security group of the VPCProperties : VpcConfig SecurityGroupIds
# Attach the "LabRole" IAM role to grant necessary permissions. Properties : Role
# Add environment variables: dbuser, host, and password to connect to the RDS instance. Properties : Variables
# Attach the Lambda Layer for MySQL packages to enable database interaction within the function. Properties : Layers
# Lambda Handler is the lambda file name combined with function name. Properties : Handler
# Lambda code from S Bucket. Properties : Code
# Keep Runtime environment as pythonProperties : Runtime
Keeping the formatting below I am running into Invalid template property or properties BooksUpdater BooksHandler, BooksBucket, LambdaLayer, LambdaInvokePermission this error the portion of the code is here below
# todo
BooksHandler:
Type: AWS::Lambda::Function
Properties:
FunctionName: Sub $StageNameBooksHandler'
Runtime: python
Handler: lambda.lambdahandler
Role: Sub 'arn:aws:iam:::roleLabRole
Code:
SBucket: Ref SPackageBucket
SKey: Ref LambdaFunctionFileName
VpcConfig:
SubnetIds:
Ref PrivateSubnet
SecurityGroupIds:
Ref MyRDSSecurityGroup
Environment:
Variables:
dbuser: Ref DBUserName
host: GetAtt MyRDSInstance.Endpoint.Address
password: Ref DBPassword
Layers:
Ref LambdaLayer
BooksBucket:
Type: AWS::S::Bucket
Properties:
BucketName: Sub $StageName$BooksBucketName
OwnershipControls:
Rules:
ObjectOwnership: ObjectWriter
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
NotificationConfiguration:
EventBridgeConfiguration:
EventBridgeEnabled: true
BooksUpdater:
Type: AWS::Events::Rule
Properties:
Name: Sub $StageNameBooksUpdater'
EventPattern:
source:
aws.s
detailtype:
"Object Created"
detail:
bucket:
name:
Sub $StageName$BooksBucketName
object:
key:
suffix: json"
State: ENABLED
Targets:
Arn: GetAtt BooksHandler.Arn
Id: "BooksHandlerTarget"
LambdaInvokePermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: Ref BooksHandler
Action: lambda:InvokeFunction
Principal: events.amazonaws.com
SourceArn: GetAtt BooksUpdater.Arn
LambdaLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
python
Content:
SBucket: Ref SPackageBucket
SKey: Ref LambdaLayerFileName
Description: "Layer for MySQL Packages"
LayerName: Sub $StageNameMySqlLayer'
Outputs:
VPCId:
Description: VPC ID
Value: Ref MyVPC
PublicSubnetId:
Description: "Public Subnet ID
Value: Ref PublicSubnet
PrivateSubnetId:
Description: "Private Subnet ID
Value: Ref PrivateSubnet
PrivateSubnetId:
Description: "Private Subnet ID
Value: Ref PrivateSubnet
RDSInstanceEndpoint:
Description: RDS Instance Endpoint"
Value: GetAtt MyRDSInstance.Endpoint.Address
RDSInstancePort:
Description: RDS Instance Port"
Value: GetAtt MyRDSInstance.Endpoint.Port
FrontEndInstancePublicIp:
Description: Public IP of the Frontend EC instance
Value: GetAtt FrontEndECInstance.PublicIp
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
