Skip to content

Instantly share code, notes, and snippets.

View avishayil's full-sized avatar

Avishay Bar avishayil

View GitHub Profile
@avishayil
avishayil / index.js
Created December 13, 2017 09:16
Lambda function for promoting replica to master
var AWS = require('aws-sdk');
AWS.config.update({ region: 'your-region-ie:eu-central-1' });
var mysql = require('mysql');
// Better to use environment variables, but for the example we'll leave it like this
var dbClusterIdentifier = 'your-cluster';
var clusterEndpoint = 'your-cluster.cluster-identifier.your-region.rds.amazonaws.com';
var user = 'username';
var password = 'password';
@avishayil
avishayil / eb-from-bitbucket-pipelines.json
Last active January 19, 2018 00:42
Policy for bitbucket IAM user to EB
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"cloudformation:GetTemplate",
@avishayil
avishayil / beanstalk_deploy.py
Created January 19, 2018 00:36
Python deployment script to Elastic Beanstalk Application
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
# except in compliance with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an "AS IS"
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under the License.
@avishayil
avishayil / bitbucket-pipelines.yml
Created January 19, 2018 00:37
Pipelines YAML to Elastic Beanstalk Deployment
image: python:3.5.1
pipelines:
branches:
master:
- step:
script:
- apt-get update # required to install zip
- apt-get install -y zip # required for packaging up the application
- pip install boto3==1.3.0 # required for beanstalk_deploy.py
@avishayil
avishayil / route53.sh
Created October 14, 2018 17:00
Update Route53 Record With Machine IP Address
#!/bin/bash
# (optional) You might need to set your PATH variable at the top here
# depending on how you run this script
# PATH=PATH
# Hosted Zone ID e.g. BJBK35SKMM9OE
ZONEID="ZONEID"
# The CNAME you want to update e.g. hello.example.com
@avishayil
avishayil / .kitchen.yml
Created December 6, 2018 22:41
Test-Kitchen .kitchen.yml for AWS environments
---
driver:
name: ec2
platforms:
- name: windows-2016
driver_plugin: ec2
driver_config:
tags:
created-by: test-kitchen
@avishayil
avishayil / deny-policy-not-matches-ip.json
Created September 21, 2019 08:18
This IAM Policy denies any request if it doesn't originate from the explicitly mentioned IP address.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
---
- iam_role:
name: Admin
assume_role_policy_document: "{{ lookup('file','trust-okta.json') }}"
managed_policy:
- arn:aws:iam::aws:policy/AdministratorAccess
state: present
- iam_role:
---
- iam_policy:
iam_type: role
iam_name: Developer
policy_name: DeveloperAccess
policy_document: dev/policies/DeveloperAccess.json
state: present
- iam_policy:
main.yml
dev/
identity_providers/
main.yml # `iam_saml_federation` module tasks
idp_metadata.xml # idp metadata document
groups/
main.yml # `iam_group` module tasks
users/
main.yml # `iam_user` module tasks
roles/