Skip to content

Commit

Permalink
Removed all mentions of aws-vault in chapter 4 (#640)
Browse files Browse the repository at this point in the history
* Removed aws-vault deliverable

* Removed all instances of "aws-vault exec PROFILE_NAME -- "

* Removed the lingering '$' infront of one of the aws commands
  • Loading branch information
LangBledsoe authored Feb 11, 2025
1 parent c4ce71e commit c233746
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/4-cloud-computing/4.1.1-aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ Once your are signed in to AWS you can use the web based [console](https://conso
## Deliverables

- Set up AWS CLI and verify you can interact with AWS using it
- Set up aws-vault to track your credentials for you
24 changes: 12 additions & 12 deletions docs/4-cloud-computing/4.2.1-s3-cloudfront.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ For this exercise we're hosting a static HTML website using AWS S3. We will be u
5. Create the S3 Bucket. Replace *YOUR_NAME* with your name and *PROFILE_NAME* with the name of the AWS cli profile you set up. Make sure to replace *PROFILE_REGION* with the region you configured your AWS cli profile to talk to (run `cat ~/.aws/config` to see what your cli is configured to).

```bash
aws-vault exec PROFILE_NAME -- aws s3api create-bucket --bucket YOUR_NAME-dob-react --create-bucket-configuration LocationConstraint=PROFILE_REGION.
aws s3api create-bucket --bucket YOUR_NAME-dob-react --create-bucket-configuration LocationConstraint=PROFILE_REGION.
```

6. Verify that the S3 bucket was created in the AWS console.
7. Configure the Bucket for Static Website Hosting. This command specifies the bucket as one that hosts static website content as well as specifies which files to be used for the home page and error page. Don't forget to change the *YOUR_NAME* and *PROFILE_NAME* values.

```bash
aws-vault exec PROFILE_NAME -- aws s3 website s3://YOUR_NAME-dob-react --index-document index.html --error-document 404.html
aws s3 website s3://YOUR_NAME-dob-react --index-document index.html --error-document 404.html
```

8. Add tags to the S3 Bucket. While tagging resources is an optional feature in AWS, it is an important organization habit to get into.

```bash
aws-vault exec PROFILE_NAME -- aws s3api put-bucket-tagging --bucket YOUR_NAME-dob-react --tagging 'TagSet=[{Key=Client,Value=Internal},{Key=Project,Value=DOB},{Key=Environment,Value=Demo},{Key=Application,Value=React},{Key=Owner,Value=YOUR_NAME}]'
aws s3api put-bucket-tagging --bucket YOUR_NAME-dob-react --tagging 'TagSet=[{Key=Client,Value=Internal},{Key=Project,Value=DOB},{Key=Environment,Value=Demo},{Key=Application,Value=React},{Key=Owner,Value=YOUR_NAME}]'
```

9. Verify the tags were created in the AWS console.
10. Upload the contents of the *build/* folder, which contains the HTML generated from the template, to our S3 bucket.

```bash
aws-vault exec PROFILE_NAME -- aws s3 sync build/ s3://YOUR_NAME-dob-react
aws s3 sync build/ s3://YOUR_NAME-dob-react
```

11. Before your website will be visible to the outside world you need to allow outside traffic to access your bucket. AWS manages access control to S3 buckets via [Bucket Policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html). Read about bucket policies and add a policy to allow public read access.
Expand All @@ -87,14 +87,14 @@ deployed, and create an alias Record Set to forward traffic from a subdomain usi
1. Create the CloudFront Distribution. This command specifies what URL and root object to use as the origin for the web distribution. Then take note of the created distribution's ARN, Domain Name, ID, and ETag that the command outputs. The ARN can be used to add tags, the domain name is where you can reach your distribution on the web, and the ID and ETag are used to delete the distribution.

```bash
aws-vault exec PROFILE_NAME -- aws cloudfront create-distribution --origin-domain-name YOUR_NAME-dob-react.s3-website-us-west-2.amazonaws.com --default-root-object index.html
aws cloudfront create-distribution --origin-domain-name YOUR_NAME-dob-react.s3-website-us-west-2.amazonaws.com --default-root-object index.html
```

2. Navigate to the outputted CloudFront Domain Name to view your S3 content now distributed using a Web Distribution. This enables your S3 content to be accessible as fast as possible for users.
3. Tag your Distribution using the ARN from the output of step 1.

```bash
aws-vault exec PROFILE_NAME -- aws cloudfront tag-resource --resource ARN --tags 'Items=[{Key=Client,Value=Internal},{Key=Project,Value=DOB},{Key=Environment,Value=Demo},{Key=Application,Value=React},{Key=Owner,Value=YOUR_NAME}]'
aws cloudfront tag-resource --resource ARN --tags 'Items=[{Key=Client,Value=Internal},{Key=Project,Value=DOB},{Key=Environment,Value=Demo},{Key=Application,Value=React},{Key=Owner,Value=YOUR_NAME}]'
```

4. Verify the tags are added to your Distribution in the AWS console.
Expand All @@ -108,38 +108,38 @@ The following commands delete all objects in the bucket, remove the bucket and d
1. Remove all Objects from the S3 Bucket.

```bash
aws-vault exec PROFILE_NAME -- aws s3 rm s3://YOUR_NAME-dob-react --recursive
aws s3 rm s3://YOUR_NAME-dob-react --recursive
```

2. Delete the empty S3 Bucket.

```bash
aws-vault exec PROFILE_NAME -- aws s3api delete-bucket --bucket YOUR_NAME-dob-react
aws s3api delete-bucket --bucket YOUR_NAME-dob-react
```

3. Get the configuration for the distribution, using its ID from the command earlier, and save it to a file.

```bash
aws-vault exec PROFILE_NAME -- aws cloudfront get-distribution-config --id ID > distribution-config
aws cloudfront get-distribution-config --id ID > distribution-config
```

4. Edit the `distribution-config` file so that it only contains the contents of the *DistributionConfig* field and change `Enabled` to false.
5. Disable the distribution and record the ETag from the output.

```bash
aws-vault exec PROFILE_NAME -- aws cloudfront update-distribution --id ID --if-match ETAG --distribution-config file://distribution-config
aws cloudfront update-distribution --id ID --if-match ETAG --distribution-config file://distribution-config
```

6. The distribution can not be deleted until each of the edge locations have been disabled. Check for the status `Deployed`:

```bash
aws-vault exec PROFILE_NAME -- aws cloudfront get-distribution --id ID
aws cloudfront get-distribution --id ID
```

7. Delete the Distribution using its ID and the ETag from the update-distribution command.

```bash
aws-vault exec PROFILE_NAME -- aws cloudfront delete-distribution --id ID --if-match ETAG
aws cloudfront delete-distribution --id ID --if-match ETAG
```

## Knowledge Check
Expand Down
10 changes: 5 additions & 5 deletions docs/4-cloud-computing/4.2.2-ec2.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ Through these steps you will build two servers on AWS, one as a Jenkins controll
- Find an Amazon Linux 2023 AMI on the marketplace.

```bash
aws-vault exec PROFILE_NAME -- aws ec2 run-instances --image-id AMI --count 1 --instance-type t2.micro --key-name KEY_PAIR_NAME --security-groups SECURITY_GROUP
aws ec2 run-instances --image-id AMI --count 1 --instance-type t2.micro --key-name KEY_PAIR_NAME --security-groups SECURITY_GROUP
```

4. Name your server, replace Justin with your name in lower case:

```bash
aws-vault exec PROFILE_NAME -- aws ec2 create-tags --resources INSTANCE_ID --tags "Key=Name,Value=justin-jenkins-controller"
aws ec2 create-tags --resources INSTANCE_ID --tags "Key=Name,Value=justin-jenkins-controller"
```

5. Login to your host. The default username might be ec2-user, but you may have to search for the correct username, and you will have to use your private key file:
Expand All @@ -74,13 +74,13 @@ ssh -i PRIVATE_KEY_FILE -l USERNAME PUBLIC_DNS_NAME
7. To stop your instance at the end of the day:

```bash
aws-vault exec PROFILE_NAME -- aws ec2 stop-instances --instance-ids INSTANCE_ID
aws ec2 stop-instances --instance-ids INSTANCE_ID
```

8. To start up your instance the next day:

```bash
aws-vault exec PROFILE_NAME -- aws ec2 start-instances --instance-ids INSTANCE_ID
aws ec2 start-instances --instance-ids INSTANCE_ID
```

9. The DNS name is not persistent through shutdown and start. Run step 6 again to get the hostname of your instance.
Expand All @@ -90,7 +90,7 @@ aws-vault exec PROFILE_NAME -- aws ec2 start-instances --instance-ids INSTANCE_I
**To permanently destroy and delete your instance:**

```bash
aws-vault exec PROFILE_NAME -- $ aws ec2 terminate-instances --instance-ids INSTANCE_ID
aws ec2 terminate-instances --instance-ids INSTANCE_ID
```

### Create a Jenkins agent instance (open ended exercise)
Expand Down

0 comments on commit c233746

Please sign in to comment.