AWS

Amazon Web Services

Lambda Java samples:

User credentials

Instead of sharing the credentials of the AWS account root user, create individual IAM users, granting each user only the permissions they require.

Follow the best practice of using the root user only to create your first IAM user.

There are two types of credentials:

Serverless blog web application architecture

IPv6 info

Lambda authorizer (API gateway)

A lambda authorizer (API gateway) requires a resource based policy statement, with principalId and policy document.

JSON example

   1 {
   2   "principalId": "user|12345",
   3   "policyDocument": {
   4     "Version": "2012-10-17",
   5     "Statement": [
   6       {
   7         "Action": "execute-api:Invoke",
   8         "Effect": "Allow",
   9         "Resource": "arn:aws:execute-api:region:account-id:api-id/stage/METHOD/path"
  10       }
  11     ]
  12   },
  13   "context": {
  14     "stringKey": "value",
  15     "numberKey": 123,
  16     "booleanKey": true
  17   }
  18 }

Add inbound rule RDS to lambda

   1 aws rds describe-db-instances \
   2     --db-instance-identifier rds-instance-identifier \
   3     --query "DBInstances[0].VpcSecurityGroups[*].VpcSecurityGroupId" \
   4     --output text
   5 
   6 aws lambda get-function-configuration \
   7     --function-name lambda-function-name \
   8     --query "VpcConfig.SecurityGroupIds[*]" \
   9     --output text
  10 
  11 
  12 aws ec2 authorize-security-group-ingress \
  13     --group-id sg-rds12345678 \
  14     --protocol tcp \
  15     --port 5432 \
  16     --source-group sg-lambda87654321

AWS (last edited 2026-07-24 18:46:08 by vitor)