Skip to content

Instantly share code, notes, and snippets.

@cagdas1
cagdas1 / create_user.m
Last active July 11, 2017 12:50
AWS Cognito IOS-SDK for creating User
AWSCognitoIdentityUserAttributeType * phone = [AWSCognitoIdentityUserAttributeType new];
phone.name = @"phone_number";
//phone number must be prefixed by country code
phone.value = @"+15555555555";
AWSCognitoIdentityUserAttributeType * email = [AWSCognitoIdentityUserAttributeType new];
email.name = @"email";
email.value = @"email@mydomain.com";
//register the user
[[pool signUp:@"username" password:@"password" userAttributes:@[email,phone] validationData:nil] continueWithBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserPoolSignUpResponse *> * _Nonnull task) {
@cagdas1
cagdas1 / create_user.java
Created July 11, 2017 12:50
AWS Cognito ANDROID-SDK for creating User
// create a handler for registration
SignUpHandler handler = new SignUpHandler() {
@Override
public void onSuccess(CognitoUser user, CognitoUserCodeDeliveryDetails codeDeliveryDetails) {
// If the sign up was successful, "user" is a CognitoUser object of the user who was signed up.
// "codeDeliveryDetails" will contain details about where the confirmation codes will be delivered.
}
@Override
public void onFailure(Exception exception) {
import * as ec2 from "@aws-cdk/aws-ec2";
import * as cdk from '@aws-cdk/core';
export class MyEc2AppStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Create new VPC
const vpc = new ec2.Vpc(this, 'VPC');
// Open port 22 for SSH connection from anywhere
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core';
import { MyEc2AppStack } from '../lib/my-ec2-app-stack';
const app = new cdk.App();
new MyEc2AppStack(app, 'MyEc2AppStack', {
env: {
region: process.env.AWS_REGION,
account: process.env.ACCOUNT_ID
import asyncio
import concurrent.futures
import boto3
from timeit import default_timer as timer
# Replace with your own AWS profile
session = boto3.Session(profile_name="replace_me")
regions = ["us-east-1", "us-east-2", "us-west-1", "us-west-2", "eu-west-1", "eu-west-2", "eu-west-3"]
async def non_blocking(executor):
@cagdas1
cagdas1 / driftDetection.js
Last active July 21, 2019 21:49
Cloudformation Drift Detection
//env variable for aws profile
process.env.AWS_PROFILE = "your_profile";
const axios = require("axios").default;
const AWS = require("aws-sdk");
const regions = ["us-west-1", "us-west-2"]
const SLACK_URL = "https://hooks.slack.com/services/CHANGE";
async function getAllStacks(cloudformation){
@cagdas1
cagdas1 / main.go
Created July 23, 2019 06:54
ECS Demo App
package main
import (
"net/http"
"encoding/json"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
@cagdas1
cagdas1 / Dockerfile
Created July 23, 2019 06:58
ECS Demo Dockerfile
# Multi-stage layout
FROM golang:1.12 as builder
ENV GO111MODULE=on
WORKDIR /app
COPY go.mod .
COPY go.sum .
@cagdas1
cagdas1 / index.ts
Created July 23, 2019 07:01
ECS Demo ECR Repo
import cdk = require("@aws-cdk/core");
import ecr = require("@aws-cdk/aws-ecr");
import ecs = require("@aws-cdk/aws-ec2");
import ecs_patterns = require('@aws-cdk/aws-ecs-patterns');
export default class EcsGoAPIStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps){
super(scope, id, props);
const ecrRepo = new ecr.Repository(this, "GoAPI", {
@cagdas1
cagdas1 / index.ts
Last active February 23, 2020 17:10
ECS Demo Finished CDK File
import * as cdk from "@aws-cdk/core";
import * as ec2 from "@aws-cdk/aws-ec2";
import * as ecs from '@aws-cdk/aws-ecs';
import * as ecs_patterns from '@aws-cdk/aws-ecs-patterns';
import { config } from "dotenv";
config();
class EcsGoAPIStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps){
super(scope, id, props);