This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Main Terraform file with the providers | |
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 4.0" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#AMI filter for Amazon Linux HVM | |
data "aws_ami" "amazon_linux" { | |
most_recent = true | |
filter { | |
name = "name" | |
values = ["amzn2-ami-hvm-2.0*"] | |
} | |
filter { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_s3_bucket" "yourbucketname" { | |
bucket = "yourbucketname" | |
acl = "private" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Jenkins Bucket Policy | |
resource "aws_iam_policy" "jenkins_s3_write_policy" { | |
name = "jenkins_s3_write_policy" | |
policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Jenkins IAM role | |
resource "aws_iam_role" "jenkins_role" { | |
name = "jenkins_role" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Project variables | |
variable "aws_region" { | |
default = "us-east-1" | |
} | |
variable "vpc_cidr_block" { | |
description = "CIDR block for VPC" | |
type = list(string) | |
default = [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Jenkins Security group and instance output | |
output "instance_public_ip" { | |
value = aws_instance.jenkins_server.public_ip | |
} |
OlderNewer