Skip to content

Instantly share code, notes, and snippets.

View bmwitcher's full-sized avatar

Bryant Witcher bmwitcher

View GitHub Profile
@bmwitcher
bmwitcher / .gitlab-ci.yml
Created December 30, 2020 20:03
Gitlab.yml file for creating CI/CD
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
- 'AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}'
- 'AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}'
- 'AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}'
variables:
@bmwitcher
bmwitcher / deleteuser.py
Created November 24, 2020 04:29
deleting user in iam in aws
import boto3
iam = boto3.client('iam')
response = iam.detach_user_policy(
UserName='pythontestuser',
PolicyArn='arn:aws:iam::aws:policy/AmazonEC2FullAccess'
)
response = iam.delete_user(
@bmwitcher
bmwitcher / iamawstest.py
Created November 24, 2020 04:27
creating an iam user in aws
import boto3
iam = boto3.client('iam')
response = iam.create_user(
UserName='pythontestuser'
)
response = iam.attach_user_policy(
UserName='pythontestuser',
@bmwitcher
bmwitcher / stopec2.py
Last active November 21, 2020 18:25
stop ec2 lambda python code
# Stops the EC2 instances
import boto3
region = 'us-east-1'
instances = ['i-12345', 'i-2345']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
@bmwitcher
bmwitcher / startec2.py
Created November 21, 2020 18:24
start ec2 lambda python code
# Starts the EC2 instances
import boto3
region = 'us-east-1'
instances = ['i-12345', 'i-2345']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.start_instances(InstanceIds=instances)
print('started your instances: ' + str(instances))
@bmwitcher
bmwitcher / ec2startstop.txt
Created November 21, 2020 18:23
Give Lambda permission to execute listed functions
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
@bmwitcher
bmwitcher / index.html
Created October 31, 2020 13:39
Index Gists
<html>
<h1>Level Up In Tech</h1>
<p> Learning it. Labbing it. Leveling Up</p>
<p>This is a simple static website, built and delivered from a docker container</p>
<p>Visit us here: <a href="https://levelupintech.com/">Level Up In Tech</a></p>
</html>
@bmwitcher
bmwitcher / Dockerfile
Created October 31, 2020 13:34
Nginx Dockerfile
FROM ubuntu
RUN apt-get update
RUN apt-get install nginx -y
COPY index.html /var/www/html/
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
@bmwitcher
bmwitcher / vpc_endpoint.tf
Created October 19, 2020 21:25
creating and attaching endpoints for vpc endpoint lab
resource "aws_vpc_endpoint" "s3" {
vpc_id = aws_vpc.My_VPC.id
service_name = "com.amazonaws.us-east-1.s3"
}
# associate route table with VPC endpoint
resource "aws_vpc_endpoint_route_table_association" "Private_route_table_association" {
route_table_id = aws_route_table.My_VPC_PRIVATE_route_table.id
vpc_endpoint_id = aws_vpc_endpoint.s3.id
}
@bmwitcher
bmwitcher / ec2iam.tf
Created October 19, 2020 21:24
creating iam roles, polcies, and attachemts for vpc endpoint lab
resource "aws_iam_role" "ec2_s3_access_role" {
name = "ec2-s3"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"