This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/gorilla/mux" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_autoscaling_group" "example" { | |
launch_configuration = "${aws_launch_configuration.example.id}" | |
load_balancers = ["${aws_elb.example.name}"] | |
availability_zones = ["eu-west-1b", "eu-west-1a"] | |
min_size = 2 | |
max_size = 5 | |
tag { | |
key = "Name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
region = "eu-west-1" | |
} | |
data "aws_availability_zones" "available" {} | |
resource "aws_security_group" "instance" { | |
name = "go-api-instance" | |
ingress { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_security_group" "elb" { | |
name = "terraform-go-api" | |
ingress { | |
from_port = 80 | |
to_port = 80 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_launch_configuration" "example" { | |
image_id = "ami-58d7e821" | |
instance_type = "t2.micro" | |
security_groups = ["${aws_security_group.instance.id}"] | |
user_data = <<-EOF | |
#!/bin/bash | |
echo "Hello, World" > index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
access_key = "xxx" | |
secret_key = "xxxxx" | |
region = "us-east-1" | |
} | |
resource "aws_instance" "example" { | |
ami = "ami-2757f631" | |
instance_type = "t2.micro" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import boto3 | |
>>> rekognition = boto3.client('rekognition', 'eu-west-1') | |
>>> response = rekognition.detect_labels(Image={"S3Object":{"Bucket":"imgur-serverless-v2", "Name": "dogs.jpg" }}) | |
>>> response | |
{'Labels': [{'Name': 'Animal', 'Confidence': 92.09390258789062}, {'Name': 'Canine', 'Confidence': 92.09390258789062}, {'Name': 'Collie', 'Confidence': 92.09390258789062}, {'Name': 'Dog', 'Confidence': 92.09390258789062}, {'Name': 'Mammal', 'Confidence': 92.09390258789062}, {'Name': 'Pet', 'Confidence': 92.09390258789062}, {'Name': 'Husky', 'Confidence': 53.51436233520508}, {'Name': 'Eskimo Dog', 'Confidence': 51.68663787841797}],'OrientationCorrection': 'ROTATE_0', 'ResponseMetadata': {'RequestId': '3826c201-1a50-11e8-9262-597ffc9fcbba', 'HTTPStatusCode': 200, 'HTTPHeaders': {'content-type': 'application/x-amz-json-1.1', 'date': 'Sun, 25 Feb2018 17:20:47 GMT', 'x-amzn-requestid': '3826c201-1a50-11e8-9262-597ffc9fcbba', 'content-length': '436', 'connection': 'keep-alive'}, 'RetryAttempts': 0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import os | |
import uuid | |
rekognition = boto3.client('rekognition', 'eu-west-1') | |
dynamo = boto3.resource('dynamodb', 'eu-west-1') | |
def tagImage(event, content): | |
key = uuid.uuid4().hex | |
location = event['Records'][0]['s3']['object']['key'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configure (config) { | |
if (typeof config !== 'object' || Array.isArray(config)) { | |
throw new Error('[CognitoAuth error] valid option object required') | |
} | |
this.userPool = new CognitoUserPool({ | |
UserPoolId: config.IdentityPoolId, | |
ClientId: config.ClientId | |
}) | |
Config.region = config.region | |
Config.credentials = new CognitoIdentityCredentials({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: imgur-clone-functions | |
frameworkVersion: ">=1.1.0 <2.0.0" | |
custom: | |
bucket: imgur-serverless | |
provider: | |
name: aws | |
runtime: python3.6 |