Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from bregman-arie:master #95

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions topics/aws/exercises/launch_ec2_web_instance/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,58 @@ echo "<h1>I made it! This is is awesome!</h1>" > /var/www/html/index.html
9. In the security group section, add a rule to accept HTTP traffic (TCP) on port 80 from anywhere
10. Click on "Review" and then click on "Launch" after reviewing.
11. If you don't have a key pair, create one and download it.

12. ### Solution using Terraform

```

provider "aws" {
region = "us-east-1" // Or your desired region
}

resource "aws_instance" "web_server" {
ami = "ami-12345678" // Replace with the correct AMI for Amazon Linux 2
instance_type = "t2.micro" // Or any instance type with 1 vCPU and 1 GiB memory

tags = {
Name = "web-1"
Type = "web"
}

root_block_device {
volume_size = 8 // Or any desired size
delete_on_termination = true
}

provisioner "remote-exec" {
inline = [
"sudo yum update -y",
"sudo yum install -y httpd",
"sudo systemctl start httpd",
"sudo bash -c 'echo \"I made it! This is awesome!\" > /var/www/html/index.html'",
"sudo systemctl enable httpd"
]

connection {
type = "ssh"
user = "ec2-user"
private_key = file("~/.ssh/your_private_key.pem") // Replace with the path to your private key
host = self.public_ip
}
}

security_group_ids = [aws_security_group.web_sg.id]
}

resource "aws_security_group" "web_sg" {
name = "web_sg"
description = "Security group for web server"

ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ resource "aws_dynamodb_table" "users" {

global_secondary_index {
hash_key =

name =
projection_type =
}
}
2 changes: 1 addition & 1 deletion topics/cicd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

A development practice where developers integrate code into a shared repository frequently. It can range from a couple of changes every day or a week to a couple of changes in one hour in larger scales.

Each piece of code (change/patch) is verified, to make the change is safe to merge. Today, it's a common practice to test the change using an automated build that makes sure the code can be integrated. It can be one build which runs several tests in different levels (unit, functional, etc.) or several separate builds that all or some has to pass in order for the change to be merged into the repository.
Each piece of code (change/patch) is verified to make sure that the change is safe to merge. Today, it's a common practice to test the change using an automated build that makes sure the code can be integrated. It can be one build which runs several tests in different levels (unit, functional, etc.) or several separate builds that all or some has to pass in order for the change to be merged into the repository.
</b></details>

<details>
Expand Down
Loading