This commit is contained in:
Arie Bregman
2022-08-25 09:17:29 +03:00
parent 03a92d5bea
commit 48db2d4664
6 changed files with 257 additions and 77 deletions

View File

@@ -0,0 +1,15 @@
# Create buckets
## Objectives
1. Create the following buckets:
1. Private bucket
1. eu-west-2 region
2. Upload a single file to the bucket. Any file.
2. Public bucket
1. eu-west-1 region
2. Versioning should be enabled
## Solution
Click [here](solution.md) to view the solution

View File

@@ -0,0 +1,28 @@
import pulumi
import pulumi_aws as aws
# Private Bucket
private_bucket = aws.s3.Bucket("my-first-private-bucket",
acl="private",
tags={
"Environment": "Exercise",
"Name": "My First Private Bucket"},
region="eu-west-2"
)
# Bucket Object
aws.s3.BucketObject("bucketObject",
key="some_object_key",
bucket=private_bucket.id,
content="object content")
# Public Bucket
aws.s3.Bucket("my-first-public-bucket",
acl="private",
tags={
"Environment": "Exercise",
"Name": "My First Public Bucket"},
region="eu-west-1",
versioning=aws.s3.BucketVersioningArgs(enabled=True)
)

View File

@@ -0,0 +1,43 @@
# Create buckets
## Objectives
1. Create the following buckets:
1. Private bucket
1. eu-west-2 region
2. Upload a single file to the bucket. Any file.
2. Public bucket
1. eu-west-1 region
2. Versioning should be enabled
## Solution
### Console
For the first bucket:
1. Go to S3 service in the AWS console. If not in buckets page, click on "buckets" in the left side menu
2. Click on "Create bucket"
3. Give a globally unique name for your bucket
4. Choose the region "eu-west-2"
5. Click on "Create bucket"
6. Click on the bucket name
7. Under "objects" click on "Upload" -> "Add files" -> Choose file to upload -> Click on "Upload"
For the second bucket:
1. Go to S3 service in the AWS console. If not in buckets page, click on "buckets" in the left side menu
2. Click on "Create bucket"
3. Give a globally unique name for your bucket
4. Choose the region "eu-west-1"
5. Make sure to uncheck the box for "Private bucket" to make it public
6. Make sure to check the enable box for "Bucket Versioning"
7. Click on "Create bucket"
### Terraform
Click [here](terraform/main.tf) to view the solution
### Pulumi - Python
Click [here](pulumi/__main__.py) to view the solution

View File

@@ -0,0 +1,40 @@
resource "aws_s3_bucket" "private_bucket" {
bucket = "my-first-private-bucket"
region = "eu-west-2"
acl = "private"
tags = {
Name = "My First Private Bucket"
Environment = "Exercise"
}
}
resource "aws_s3_bucket_acl" "private_bucket_acl" {
bucket = aws_s3_bucket.private_bucket.id
acl = "private"
}
resource "aws_s3_bucket" "public_bucket" {
bucket = "my-first-public-bucket"
region = "eu-west-1"
tags = {
Name = "My First Public Bucket"
Environment = "Exercise"
}
versioning {
enabled = true
}
}
resource "aws_s3_bucket_acl" "public_bucket_acl" {
bucket = aws_s3_bucket.public_bucket.id
acl = "public-read"
}
resource "aws_s3_bucket_object" "bucket_object" {
bucket = "my-first-private-bucket"
key = "some_object_key"
content = "object content"
}