Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. @sats17 sats17 revised this gist Jul 20, 2022. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions node.js-typescript-connectors
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    1) DynamoDB -
    import AWS = require("aws-sdk");
    let options = {
    apiVersion: '2012-08-10',
    region: 'us-east-1',
    }

    options['endpoint'] = new AWS.Endpoint("http://localhost:4566")
    console.log(options)

    const dynamoDB = new AWS.DynamoDB(options);
    console.log(dynamoDB)
    dynamoDB.listTables({Limit: 10}, function(err, data) {
    if (err) {
    console.log("Error", err.code);
    } else {
    console.log("Table names are ", data.TableNames);
    }
    });
  2. @sats17 sats17 revised this gist Mar 19, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    version: '3.8'
    services:
    redis:
    container_name: "redis"
    image: redis:alpine
    ports:
    - "6379:6379" # To Connect redis from local cmd use : docker exec -it cores-redis redis-cli
    localstack:
    container_name: "localstack" # Container name in your docker
    image: localstack/localstack:latest # Will download latest version of localstack
  3. @sats17 sats17 revised this gist Mar 10, 2021. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion localstack-sns-examples.txt
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,18 @@
    # aws --endpoint-url=http://localhost:4566 sns list-topics

    3) list subscriptions -
    # aws --endpoint-url=http://localhost:4566 sns list-subscriptions
    # aws --endpoint-url=http://localhost:4566 sns list-subscriptions

    4) publish message -
    # aws --endpoint-url=http://localhost:4566 sns publish --topic-arn "arn:aws:sns:us-east-1:000000000000:ingest-topic" --message file://message.txt --message-attributes file://attributes.json

    -- message.txt
    my message to publish

    -- attributes.json
    {
    "key": {
    "DataType": "String",
    "StringValue": "value"
    }
    }
  4. @sats17 sats17 revised this gist Mar 10, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-aws-localstack-sdk-connector.txt
    Original file line number Diff line number Diff line change
    @@ -13,5 +13,5 @@ AmazonSQSClientBuilder.standard()

    3) SNS Connection :
    AmazonSNSClientBuilder.standard()
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:4575", "eu-west-1"))
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:4566", "us-east-1"))
    .build();
  5. @sats17 sats17 revised this gist Mar 10, 2021. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions java-aws-localstack-sdk-connector.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    1) S3 Connection :
    AmazonS3ClientBuilder
    .standard()
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:4566/", "us-east-1")) // localstack endpoint configuration
    .withCredentials(new DefaultAWSCredentialsProviderChain())
    .withPathStyleAccessEnabled(true) // Disable virtualhost style connection and enable path style s3 bucket
    .build();

    2) SQS Connection :
    AmazonSQSClientBuilder.standard()
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:4566", "us-east-1"))
    .withCredentials(new DefaultAWSCredentialsProviderChain());

    3) SNS Connection :
    AmazonSNSClientBuilder.standard()
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:4575", "eu-west-1"))
    .build();
  6. @sats17 sats17 revised this gist Mar 9, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion localstack-sns-examples.txt
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,7 @@
    # aws --endpoint-url=http://localhost:4566 sns create-topic --name my-test-topic

    2) list all sns topics -
    # aws --endpoint-url=http://localhost:4566 sns list-topic
    # aws --endpoint-url=http://localhost:4566 sns list-topics

    3) list subscriptions -
    # aws --endpoint-url=http://localhost:4566 sns list-subscriptions
  7. @sats17 sats17 revised this gist Mar 7, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    version: '2.1'
    version: '3.8'
    services:
    localstack:
    container_name: "localstack" # Container name in your docker
  8. @sats17 sats17 revised this gist Mar 4, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion localstack-terraform-provider.tf
    Original file line number Diff line number Diff line change
    @@ -8,5 +8,8 @@ provider "aws" {
    s3_force_path_style = true
    # Starting with localstack version 0.11.0, all APIs are exposed via a single edge service,
    # which is accessible on http://localhost:4566 by default
    endpoints = "http://localhost:4566"
    endpoints = {
    s3 = "http://localhost:4566"
    sqs = "https://localhost:4566"
    }
    }
  9. @sats17 sats17 revised this gist Mar 4, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion localstack-s3-example.txt
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name> --notification-configuration file://<configuration-file-name>.json

    9) Get bucket notification configuration -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name>
    # aws --endpoint-url=http://localhost:4566 s3api get-bucket-notification-configuration --bucket <bucket-name>

    10) Set bucket policy -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-policy --bucket <bucket-name> --policy file://<policy-file>.json
  10. @sats17 sats17 revised this gist Mar 2, 2021. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions localstack-s3-example.txt
    Original file line number Diff line number Diff line change
    @@ -13,13 +13,16 @@
    6) Access file via URL(File name was download.jpg) -
    # http://localhost:4566/my-test-bucket/download.jpg

    7) Create bucket notification configuration -
    7) Delete object from bucket -
    # aws --endpoint-url=http://localhost:4566 s3api delete-object --bucket <bucket-name> --key <file-name.format>

    8) Create bucket notification configuration -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name> --notification-configuration file://<configuration-file-name>.json

    8) Get bucket notification configuration -
    9) Get bucket notification configuration -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name>

    9) Set bucket policy -
    10) Set bucket policy -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-policy --bucket <bucket-name> --policy file://<policy-file>.json

    10) Get bukcet policy -
  11. @sats17 sats17 revised this gist Mar 2, 2021. No changes.
  12. @sats17 sats17 revised this gist Mar 2, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion localstack-s3-example.txt
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,10 @@
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name> --notification-configuration file://<configuration-file-name>.json

    8) Get bucket notification configuration -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name>
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name>

    9) Set bucket policy -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-policy --bucket <bucket-name> --policy file://<policy-file>.json

    10) Get bukcet policy -
    # aws --endpoint-url=http://localhost:4566 s3api get-bucket-policy --bucket <bucket-name>
  13. @sats17 sats17 revised this gist Mar 2, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion localstack-s3-example.txt
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,10 @@
    # aws --endpoint-url="http://localhost:4566" s3 ls s3://my-test-bucket

    6) Access file via URL(File name was download.jpg) -
    # http://localhost:4566/my-test-bucket/download.jpg
    # http://localhost:4566/my-test-bucket/download.jpg

    7) Create bucket notification configuration -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name> --notification-configuration file://<configuration-file-name>.json

    8) Get bucket notification configuration -
    # aws --endpoint-url=http://localhost:4566 s3api put-bucket-notification-configuration --bucket <bucket-name>
  14. @sats17 sats17 revised this gist Mar 2, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -18,3 +18,9 @@

    7) delete queue -
    # aws --endpoint-url=http://localhost:4566 sqs delete-queue --queue-url <queue-url>

    8) set attributes -
    # aws --endpoint-url=http://localhost:4566 sqs set-queue-attributes --queue-url=<queue-url> --attributes file://<file-name>.json

    9) get attributes -
    # aws --endpoint-url=http://localhost:4566 sqs get-queue-attributes --queue-url=<queue-url>
  15. @sats17 sats17 revised this gist Mar 2, 2021. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -3,15 +3,17 @@ services:
    localstack:
    container_name: "localstack" # Container name in your docker
    image: localstack/localstack:latest # Will download latest version of localstack
    #image: localstack/localstack-full:latest # Full image support WebUI
    ports:
    - "4566:4566" # Default port forward
    - "9200:4571" # Elasticsearch port forward
    #- "8080:8080: # WebUI port forward
    environment:
    - SERVICES=es, s3, ec2, dynamodb, elasticcache, sqs #AWS Services that you want in your localstack
    - DEBUG=1 #Debug level 1 if you want to logs, 0 if you want to disable
    - START_WEB=0
    - DEBUG=1 # Debug level 1 if you want to logs, 0 if you want to disable
    - START_WEB=0 # Flag to control whether the Web UI should be started in Docker
    - LAMBDA_REMOTE_DOCKER=0
    - DATA_DIR=/tmp/localstack/data
    - DATA_DIR=/tmp/localstack/data # Local directory for saving persistent data(Example: es storage)
    - DEFAULT_REGION=us-east-1
    volumes:
    - './.localstack:/tmp/localstack'
  16. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -16,3 +16,5 @@
    6) purge queue -
    # aws --endpoint-url=http://localhost:4566 sqs purge-queue --queue-url <queue-url>

    7) delete queue -
    # aws --endpoint-url=http://localhost:4566 sqs delete-queue --queue-url <queue-url>
  17. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,9 @@
    4) send message -
    # aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url <queue-url> --message-body <message>

    5) purge queue -
    5) receive message -
    # aws --endpoint-url=http://localhost:4566 sqs receive-message --queue-url <queue-url>

    6) purge queue -
    # aws --endpoint-url=http://localhost:4566 sqs purge-queue --queue-url <queue-url>

  18. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,6 @@
    4) send message -
    # aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url <queue-url> --message-body <message>

    5) purge queue -
    # aws --endpoint-url=http://localhost:4566 sqs purge-queue --queue-url <queue-url>

  19. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,12 @@
    1) Create queue -
    # aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name my-test-queue

    2) list queue -
    2) Get queue url -
    # aws --endpoint-url=http://localhost:4566 sqs get-queue-url --queue-name <queue-name>

    3) list queue -
    # aws --endpoint-url=http://localhost:4566 sqs list-queues

    3) send message -
    4) send message -
    # aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url <queue-url> --message-body <message>

  20. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -3,3 +3,6 @@

    2) list queue -
    # aws --endpoint-url=http://localhost:4566 sqs list-queues

    3) send message -
    # aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url <queue-url> --message-body <message>
  21. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions localstack-sqs-example.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1) Create queue -
    # aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name my-test-queue

    2) list queue -
    # aws --endpoint-url=http://localhost:4566 sqs list-queues
  22. @sats17 sats17 revised this gist Mar 1, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions localstack-sns-examples.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1) Create sns topic -
    # aws --endpoint-url=http://localhost:4566 sns create-topic --name my-test-topic

    2) list all sns topics -
    # aws --endpoint-url=http://localhost:4566 sns list-topic
  23. @sats17 sats17 revised this gist Feb 28, 2021. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions localstack-terraform-provider.tf
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,5 @@ provider "aws" {
    s3_force_path_style = true
    # Starting with localstack version 0.11.0, all APIs are exposed via a single edge service,
    # which is accessible on http://localhost:4566 by default
    endpoints {
    s3 = "http://localhost:4566"
    dynamodb = "http://localhost:4566"
    }
    endpoints = "http://localhost:4566"
    }
  24. @sats17 sats17 revised this gist Feb 28, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions localstack-terraform-provider.tf
    Original file line number Diff line number Diff line change
    @@ -10,5 +10,6 @@ provider "aws" {
    # which is accessible on http://localhost:4566 by default
    endpoints {
    s3 = "http://localhost:4566"
    dynamodb = "http://localhost:4566"
    }
    }
  25. @sats17 sats17 revised this gist Feb 28, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions localstack-terraform-provider.tf
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@ provider "aws" {
    skip_requesting_account_id = true
    skip_metadata_api_check = true
    s3_force_path_style = true
    # Starting with localstack version 0.11.0, all APIs are exposed via a single edge service,
    # which is accessible on http://localhost:4566 by default
    endpoints {
    s3 = "http://localhost:4566"
    }
  26. @sats17 sats17 revised this gist Feb 28, 2021. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions localstack-terraform-provider.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    provider "aws" {
    region = "us-east-1"
    access_key = "test"
    secret_key = "test"
    skip_credentials_validation = true
    skip_requesting_account_id = true
    skip_metadata_api_check = true
    s3_force_path_style = true
    endpoints {
    s3 = "http://localhost:4566"
    }
    }
  27. @sats17 sats17 revised this gist Feb 28, 2021. 2 changed files with 4 additions and 4 deletions.
    2 changes: 1 addition & 1 deletion docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ services:
    image: localstack/localstack:latest # Will download latest version of localstack
    ports:
    - "4566:4566" # Default port forward
    - "4571:4571" # Elasticsearch port forward
    - "9200:4571" # Elasticsearch port forward
    environment:
    - SERVICES=es, s3, ec2, dynamodb, elasticcache, sqs #AWS Services that you want in your localstack
    - DEBUG=1 #Debug level 1 if you want to logs, 0 if you want to disable
    6 changes: 3 additions & 3 deletions localstack-es-example.txt
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,13 @@
    (Note: It take around 5-10 min to up the domain in localstack)

    2) Check if domain is up or not(Default port is 4571) -
    # curl -X GET "http://localhost:4571"
    # curl -X GET "http://localhost:9200"

    3) Create new index in your domain -
    # curl -X PUT "localhost:4571/newindex?pretty"
    # curl -X PUT "localhost:9200/newindex?pretty"

    4) List all indices from your domain -
    # curl -X GET "http://localhost:4571/_cat/indices?pretty"
    # curl -X GET "http://localhost:9200/_cat/indices?pretty"

    5) List all elasticsearch domains -
    # aws --endpoint-url=http://localhost:4566 es list-domain-names
  28. @sats17 sats17 revised this gist Feb 28, 2021. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions localstack-es-example.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    1) Create es domain -
    # aws --endpoint-url=http://localhost:4566 es create-elasticsearch-domain --domain-name dev-domain --elasticsearch-version 6.8.1
    (Note: It take around 5-10 min to up the domain in localstack)

    2) Check if domain is up or not(Default port is 4571) -
    # curl -X GET "http://localhost:4571"

    3) Create new index in your domain -
    # curl -X PUT "localhost:4571/newindex?pretty"

    4) List all indices from your domain -
    # curl -X GET "http://localhost:4571/_cat/indices?pretty"

    5) List all elasticsearch domains -
    # aws --endpoint-url=http://localhost:4566 es list-domain-names

    6) Delete domain from elasticsearch -
    # aws --endpoint-url=http://localhost:4566 es delete-elasticsearch-domain --domain-name dev-domain
  29. @sats17 sats17 renamed this gist Feb 28, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  30. @sats17 sats17 renamed this gist Feb 28, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.