Skip to content

gustavomf-cit/localstack_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aws stuff

Deploy lambda

awslocal --endpoint-url=http://localhost:4574 \
                                            lambda \
                                            create-function --function-name=lambda_queue \
                                            --runtime=python3.5 \
                                            --role=lambda_policy \
                                            --handler=app.lambda_handler \
                                            --zip-file fileb://lambda.zip
{
    "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:lambda_queue",
    "FunctionName": "lambda_queue",
    "TracingConfig": {},
    "Environment": {
        "Variables": {},
        "Error": {}
    },
    "Handler": "app.lambda_handler",
    "VpcConfig": {
        "SubnetIds": [
            null
        ],
        "SecurityGroupIds": [
            null
        ]
    },
    "Role": "lambda_policy",
    "Runtime": "python3.5"
}

Generate modules

python3 -m pip install -r lambda/requirements.txt -t lambda/

Create apigateway

awslocal apigateway create-rest-api --name 'Lambda rest API'
{
    "createdDate": 1520431102,
    "id": "06A-Z3A-ZA-Z3695",
    "name": "Lambda rest API"
}

Get id above to check the resources

awslocal apigateway get-resources --rest-api-id 06A-Z3A-ZA-Z3695
{
    "items": [
        {
            "resourceMethods": {
                "GET": {}
            },
            "path": "/",
            "id": "44539A-Z2568"
        }
    ]
}

add lambda to apigateway

awslocal lambda list-functions
{
    "Functions": [
        {
            "FunctionName": "hello_world",
            "CodeSize": 50,
            "Handler": "app.lambda_handler",
            "Version": "$LATEST",
            "Environment": {},
            "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:hello_world",
            "Runtime": "python3.5"
        }
    ]
}

awslocal apigateway put-integration \
            --rest-api-id 06A-Z3A-ZA-Z3695 \
            --resource-id 44539A-Z2568 \
            --http-method GET \
            --type AWS \
            --integration-http-method GET \
            --uri aws:lambda:us-east-1:000000000000:function:hello_world

awslocal apigateway create-deployment \
                --rest-api-id 06A-Z3A-ZA-Z3695 \
                --stage-name prod

Create s3 bucket

awslocal s3 mb s3://test

Create stack using cloudformation

awslocal cloudformation create-stack --template-body file://cloudformation_templates/template.json --stack-name sqs
awslocal lambda invoke \
            --invocation-type Event \
            --function-name hello_world \
            outputfile.txt

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published