This shows how to convert a basic REST ApiGateway template to its equivalent HTTP ApiGatewayV2.
The original code before refactoring to ApiGatewayV2 comes from this article
Replace MY_PROFILE
, MY_REGION
and MY_STACK_NAME
//https://blog.bearer.sh/node-http-request/ | |
//https://nodejs.org/en/knowledge/HTTP/clients/how-to-create-a-HTTP-request/ | |
const http = require("http") | |
let body = JSON.stringify({ | |
title: "Make a request with Node's http module" | |
}) | |
let options = { |
AWSTemplateFormatVersion: 2010-09-09 | |
Description: My API Gateway and Lambda function | |
Parameters: | |
apiGatewayName: | |
Type: String | |
Default: my-api | |
apiGatewayStageName: | |
Type: String | |
AllowedPattern: "[a-z0-9]+" |
This shows how to convert a basic REST ApiGateway template to its equivalent HTTP ApiGatewayV2.
The original code before refactoring to ApiGatewayV2 comes from this article
Replace MY_PROFILE
, MY_REGION
and MY_STACK_NAME
{ | |
"Comment": "Defines the statemachine.", | |
"StartAt": "SageMaker CreateTransformJob", | |
"States": { | |
"SageMaker CreateTransformJob": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::sagemaker:createTransformJob.sync", | |
"Parameters": { | |
"BatchStrategy": "SingleRecord", | |
"DataProcessing": { |
--- | |
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Persistantly sets the hostname of a RHEL7 EC2 instance on start | |
Mappings: | |
RegionMap: | |
us-east-1: | |
'32': ami-6411e20d | |
'64': ami-7a11e213 | |
us-west-1: | |
'32': ami-c9c7978c |
AbortDocumentVersionUpload | |
AbortEnvironmentUpdate | |
AbortMultipartUpload | |
AbortVaultLock | |
AcceptAccountMapping | |
AcceptCertificateTransfer | |
AcceptDelegate | |
AcceptDirectConnectGatewayAssociationProposal | |
AcceptFxPaymentCurrencyTermsAndConditions | |
AcceptHandshake |
In [24]: node = pika.URLParameters('amqps://<>.mq.us-east-1.amazonaws.com:5671') | |
In [25]: conn = pika.BlockingConnection([node]) | |
Pika version 1.1.0 connecting to ('<>', 5671) | |
Socket connected: <socket.socket fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.178.45', 50679), raddr=('<>', 5671)> | |
SSL handshake completed successfully: <ssl.SSLSocket fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.178.45', 50679), raddr=('<>', 5671)> | |
Streaming transport linked up: (<pika.adapters.utils.io_services_utils._AsyncSSLTransport object at 0x110918ee0>, _StreamingProtocolShim: <SelectConnection PROTOCOL transport=<pika.adapters.utils.io_services_utils._AsyncSSLTransport object at 0x110918ee0> params=<URLParameters host=<>.mq.us-east-1.amazonaws.com port=5671 virtual_host=/ ssl=True>>). | |
Aborting transport connection: state=1; <ssl.SSLSocket fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.178.45', |
{ | |
"Comment": "A Catch example of the Amazon States Language using an AWS Lambda Function", | |
"StartAt": "nextstep", | |
"States": { | |
"nextstep": { | |
"Type": "Task", | |
"Resource": "arn:aws:lambda:eu-central-1:1234567890:function:catcherror", | |
"Parameters": { | |
"executionId.$": "States.Format('somestring {}', $$.Execution.Id)" | |
}, |
pipelines: | |
- step: | |
script: | |
# assuming the base image which is pulled from ecr has aws cli installed | |
- export AWS_PROFILE=deployment | |
# aws login | |
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email) | |
# docker | |
- export BUILD_ID=$BITBUCKET_BRANCH_$BITBUCKET_COMMIT_$BITBUCKET_BUILD_NUMBER | |
- docker build -t ${AWS_REGISTRY_URL}:$BUILD_ID . |