Skip to content

Instantly share code, notes, and snippets.

View theCaptN21's full-sized avatar
😎

Katoria H. theCaptN21

😎
View GitHub Profile
@theCaptN21
theCaptN21 / Boto3_Scripts
Created December 14, 2022 21:38
Boto3 & DynamoDB
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('MyFavoriteBooks')
item_1 = {"Author":"John Culkin & Mike Zazon", "BookTitle":"AWS Cookbook"}
item_2 = {"Author":"Casey Rosental & Nora Jones", "BookTitle":"Chaos Engineering"}
item_3 = {"Author":"Jonathan Allen & Thomas Blood", "BookTitle":"Reaching Cloud Velocity"}
item_4 = {"Author":"Liz Rice", "BookTitle":"Container Security"}
item_5 = {"Author":"Murat Erder, Pierre Pureur, & Eoin Woods", "BookTitle":"Continuous Architecture In Practice"}
@theCaptN21
theCaptN21 / main.tf
Last active February 2, 2023 18:29
Terraform main.tf file
#Main Terraform file with the providers
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
@theCaptN21
theCaptN21 / jenkinsinstance.tf
Created February 2, 2023 14:34
Jenkins instance
#Jenkins instance
resource "aws_instance" "jenkins_server" {
ami = "data.aws_ami.linux.id"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.jenkins_sg.id]
tags = {
Name = "Jenkins Server"
}
@theCaptN21
theCaptN21 / data.tf
Created February 2, 2023 14:35
AMI Information
#AMI filter for Amazon Linux HVM
data "aws_ami" "amazon_linux" {
most_recent = true
filter {
name = "name"
values = ["amzn2-ami-hvm-2.0*"]
}
filter {
@theCaptN21
theCaptN21 / S3Bucket.tf
Last active February 2, 2023 21:08
S3 Bucket
resource "aws_s3_bucket" "yourbucketname" {
bucket = "yourbucketname"
acl = "private"
}
#Jenkins Bucket Policy
resource "aws_iam_policy" "jenkins_s3_write_policy" {
name = "jenkins_s3_write_policy"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
@theCaptN21
theCaptN21 / Jenkinsrole.tf
Created February 2, 2023 14:38
Jenkins Role
#Jenkins IAM role
resource "aws_iam_role" "jenkins_role" {
name = "jenkins_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
@theCaptN21
theCaptN21 / Jenkinssg.tf
Last active February 2, 2023 14:56
Jenkins Security Group
#Jenkins security group parameters
resource "aws_security_group" "jenkins_sg" {
name = "jenkins_sg"
description = "Allow Jenkins Server Traffic"
ingress {
description = "Allow SSH access from My Personal Computer"
from_port = 22
to_port = 22
protocol = "tcp"
@theCaptN21
theCaptN21 / Variables.tf
Last active February 2, 2023 21:11
Project Variables
#Project variables
variable "aws_region" {
default = "us-east-1"
}
variable "vpc_cidr_block" {
description = "CIDR block for VPC"
type = list(string)
default = []
}
@theCaptN21
theCaptN21 / Output.tf
Last active February 2, 2023 21:09
Expect Outputs
#Jenkins Security group and instance output
output "instance_public_ip" {
value = aws_instance.jenkins_server.public_ip
}