Skip to content

Instantly share code, notes, and snippets.

View sdomagala's full-sized avatar

Sebastian Domagała sdomagala

  • Chorzów, Poland
View GitHub Profile
@sdomagala
sdomagala / serverless-with-trust-policy-change.yml
Created February 3, 2020 09:05
Change Trust Policy in Serverless IAM Role (or any other params other than policy)
## all other serverless.yml configuration
functions:
# your functions
provider:
name: aws
# your provider config
resources:
Resources:
# deploy to eu-central-1
export ROUTE53_NAME=sls-latency.example.com
export ROUTE53_HOSTED_ZONE_ID= #<hosted zone id>
export DOMAIN_CERT= #<certificate id in euc1>
export ACCOUNT_ID= #<account id>
serverless deploy -s dev -r eu-central-1
# deploy to us-east-1
export ROUTE53_NAME=sls-latency.example.com
export ROUTE53_HOSTED_ZONE_ID= #<hosted zone id>
---
Resources:
CustomDomain:
Type: AWS::ApiGateway::DomainName
Properties:
RegionalCertificateArn: arn:aws:acm:${opt:region}:${env:ACCOUNT_ID}:certificate/${env:DOMAIN_CERT}
DomainName: ${env:ROUTE53_NAME}
EndpointConfiguration:
Types:
- REGIONAL
service: ${self:custom.serviceName}
frameworkVersion: ">=1.36.1"
custom:
packageJson: ${file(./package.json)}
serviceName: ${self:custom.packageJson.name}
provider:
name: aws
'use strict';
module.exports.handler = (event, context, cb) => {
return cb(null, {
statusCode: 200,
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'OK'
'use strict';
module.exports.handler = (event, context, cb) => {
return cb(null, {
statusCode: 200,
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
region: process.env.LAMBDA_REGION