Skip to content

Instantly share code, notes, and snippets.

@toddlers
toddlers / ssh_key.tf
Created Jun 22, 2021 — forked from irvingpop/ssh_key.tf
Terraform external data source example - dynamic SSH key generation
View ssh_key.tf
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use:
# "${data.external.ssh_key_generator.result.public_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key_file}" (path)
data "external" "ssh_key_generator" {
program = ["bash", "${path.root}/../ssh_key_generator.sh"]
query = {
customer_name = "${var.customer_name}"
customer_group = "${var.customer_group}"
@toddlers
toddlers / s3_upload.sh
Created Mar 16, 2021 — forked from tuxfight3r/s3_upload.sh
AWS - Upload files to S3 via curl
View s3_upload.sh
#!/bin/bash -x
#Date: 21/7/2017
#Author: Mohan
#Purpose: To upload files to AWS S3 via Curl
#Uploads file at the top level folder by default
#S3 parameters
S3KEY="XXXXXXXXXXX"
S3SECRET="XXXXXXXXXXXXXXXX"
@toddlers
toddlers / all_aws_managed_policies.json
Created Mar 10, 2021 — forked from gene1wood/all_aws_managed_policies.json
A list of all AWS managed policies and they're policy documents as well as a short script to generate the list
View all_aws_managed_policies.json
This file has been truncated, but you can view the full file.
{
"APIGatewayServiceRolePolicy": {
"Arn": "arn:aws:iam::aws:policy/aws-service-role/APIGatewayServiceRolePolicy",
"AttachmentCount": 0,
"CreateDate": "2019-10-22T18:22:01+00:00",
"DefaultVersionId": "v6",
"Document": {
"Statement": [
{
View gluetags.md
aws glue tag-resource --resource-arn arn:aws:glue:eu-central-1:1234567890:job/windowTesting \
--tags-to-add '{"Account Name" : "DNS Dev"}'
$ aws glue get-tags --resource-arn arn:aws:glue:eu-central-1:1234567890:job/windowTesting
{
View iam.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": [
"arn:aws:ec2:us-east-2::instance/",
"arn:aws:ec2:us-east-2::network-interface/",
@toddlers
toddlers / main.tf
Last active Feb 3, 2021
terraform aws provider 3.23 with role and profile
View main.tf
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Installing hashicorp/aws v3.23.0...
- Installed hashicorp/aws v3.23.0 (signed by HashiCorp)
@toddlers
toddlers / index.js
Created Feb 2, 2021
nodejs http post
View index.js
//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 = {
@toddlers
toddlers / cfn.yml
Created Jan 23, 2021
sample api gateway cfn template
View cfn.yml
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]+"
View aws-cloudformation-apigateway-vs-apigatewayv2-with-lambda.md

AWS Cloudformation ApiGateway vs ApiGatewayV2 with Lambda

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

Deployment

Replace MY_PROFILE, MY_REGION and MY_STACK_NAME

@toddlers
toddlers / terraform_information.md
Last active Jan 20, 2021
terraform 0.13.4 with aws provider v3.16.0
View terraform_information.md

terraform version

✔ ~/src/old_tf
11:36 $ terraform --version
Terraform v0.13.4
+ provider registry.terraform.io/hashicorp/aws v3.16.0

Your version of Terraform is out of date! The latest version
is 0.14.4. You can update by downloading from https://www.terraform.io/downloads.html