Skip to content

Instantly share code, notes, and snippets.

View johnny-t2's full-sized avatar

Johnny-t2 johnny-t2

View GitHub Profile
@johnny-t2
johnny-t2 / create_stackset_executionrole.sh
Created February 11, 2020 07:15
Create Cloudformation StackSets Execution Role
#!/bin/bash
TARGET_ACCOUNT_ID=<target_account_id>
MASTER_ACCOUNT_ID=<master_account_id>
ROLE_NAME=OrganizationAccountAccessRole
STACK_NAME=<your_stack_name>
credentials=$(aws sts assume-role --role-session-name devdemo --role-arn arn:aws:iam::$TARGET_ACCOUNT_ID:role/$ROLE_NAME \
--query "Credentials.[AccessKeyId, SecretAccessKey,SessionToken]" \
--output text)
@johnny-t2
johnny-t2 / create_stackset_adminrole.sh
Created February 11, 2020 07:14
Create Cloudformation StackSet Admin Role Command
#!/bin/bash
STACK_NAME=<your_stack_name>
aws cloudformation create-stack \
--stack-name $STACK_NAME \
--template-url https://s3.amazonaws.com/cloudformation-stackset-sample-templates-us-east-1/AWSCloudFormationStackSetAdministrationRole.yml \
--capabilities CAPABILITY_NAMED_IAM \
--region us-east-1
aws cloudformation wait stack-create-complete --stack-name $STACK_NAME --region us-east-1
@johnny-t2
johnny-t2 / deny_all_http_s3_bucketpolicy.json
Created June 4, 2019 13:06
Bucket policy that blocks all non-secure request
{
"Version": "2012-10-17",
"Id": "Policy1559651007473",
"Statement": [
{
"Sid": "Stmt1559650947054",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::<your_bucket_name>/*",
@johnny-t2
johnny-t2 / GetAndSetCredentialsToCLIConfigureFile.sh
Last active February 15, 2020 23:28
Get Temporary credentials from sts with mfa and set credentials to cli configure.
#!/bin/bash -eu
CLI_PROFILE=<your_cli_profile>
DEV_PROFILE=<you_dev_proffile>
credentials=$(aws sts get-session-token \
--serial-number <your-mfa-device-arn> \
--token-code $1 \
--profile $CLI_PROFILE \
--query "Credentials.[AccessKeyId, SecretAccessKey,SessionToken]" \
@johnny-t2
johnny-t2 / GetCredentialAndSetEnv.sh
Last active February 15, 2020 23:29
Get temporary credentials from sts with mfa and set environment
#!/bin/bash -eu
CLI_PROFILE=<your_cli_profile>
credentials=$(aws sts get-session-token \
--serial-number <your-mfa-device-arn> \
--token-code $1 \
--profile $CLI_PROFILE \
--query "Credentials.[AccessKeyId, SecretAccessKey,SessionToken]" \
--output text)
@johnny-t2
johnny-t2 / helloworld-app.js
Last active February 15, 2020 23:27
Simple Hello WorldReact App.js
// src/App.js
import React, { Component } from 'react';
import { Header } from 'semantic-ui-react';
class App extends Component {
render() {
return (
<div>
<Header as='h1'>Hello World!</Header>