Skip to content

Commit c82bb16

Browse files
committed
Add README.md and tutorial walkthrough for script-only tutorials
1 parent 09666e5 commit c82bb16

10 files changed

Lines changed: 297 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Lambda Concurrency
2+
3+
An AWS CLI tutorial that demonstrates Iam operations.
4+
5+
## Running
6+
7+
```bash
8+
bash lambda-concurrency.sh
9+
```
10+
11+
To auto-run with cleanup:
12+
13+
```bash
14+
echo 'y' | bash lambda-concurrency.sh
15+
```
16+
17+
## What it does
18+
19+
1. Getting account concurrency limits
20+
2. Setting reserved concurrency
21+
3. Getting function concurrency
22+
4. Removing reserved concurrency
23+
24+
## Resources created
25+
26+
- Function
27+
- Role
28+
- Function Concurrency
29+
30+
The script prompts you to clean up resources when it finishes.
31+
32+
## Cost
33+
34+
Free tier eligible for most operations. Clean up resources after use to avoid charges.
35+
36+
## Related docs
37+
38+
- [AWS CLI iam reference](https://docs.aws.amazon.com/cli/latest/reference/iam/index.html)
39+
- [AWS CLI lambda reference](https://docs.aws.amazon.com/cli/latest/reference/lambda/index.html)
40+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Lambda Concurrency
2+
3+
## Prerequisites
4+
5+
1. AWS CLI installed and configured (`aws configure`)
6+
2. Appropriate IAM permissions for the AWS services used
7+
8+
## Step 1: Getting account concurrency limits
9+
10+
The script handles this step automatically. See `lambda-concurrency.sh` for the exact CLI commands.
11+
12+
## Step 2: Setting reserved concurrency
13+
14+
The script handles this step automatically. See `lambda-concurrency.sh` for the exact CLI commands.
15+
16+
## Step 3: Getting function concurrency
17+
18+
The script handles this step automatically. See `lambda-concurrency.sh` for the exact CLI commands.
19+
20+
## Step 4: Removing reserved concurrency
21+
22+
The script handles this step automatically. See `lambda-concurrency.sh` for the exact CLI commands.
23+
24+
## Cleanup
25+
26+
The script prompts you to clean up all created resources. If you need to clean up manually, check the script log for the resource names that were created.
27+

tuts/175-ec2-tags/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Ec2 Tags
2+
3+
An AWS CLI tutorial that demonstrates Ec2 operations.
4+
5+
## Running
6+
7+
```bash
8+
bash ec2-tags.sh
9+
```
10+
11+
To auto-run with cleanup:
12+
13+
```bash
14+
echo 'y' | bash ec2-tags.sh
15+
```
16+
17+
## What it does
18+
19+
1. Adding tags
20+
2. Describing tags
21+
3. Finding resources by tag
22+
4. Removing a tag
23+
24+
## Resources created
25+
26+
- Security Group
27+
- Tags
28+
29+
The script prompts you to clean up resources when it finishes.
30+
31+
## Cost
32+
33+
Free tier eligible for most operations. Clean up resources after use to avoid charges.
34+
35+
## Related docs
36+
37+
- [AWS CLI ec2 reference](https://docs.aws.amazon.com/cli/latest/reference/ec2/index.html)
38+

tuts/175-ec2-tags/ec2-tags.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Ec2 Tags
2+
3+
## Prerequisites
4+
5+
1. AWS CLI installed and configured (`aws configure`)
6+
2. Appropriate IAM permissions for the AWS services used
7+
8+
## Step 1: Adding tags
9+
10+
The script handles this step automatically. See `ec2-tags.sh` for the exact CLI commands.
11+
12+
## Step 2: Describing tags
13+
14+
The script handles this step automatically. See `ec2-tags.sh` for the exact CLI commands.
15+
16+
## Step 3: Finding resources by tag
17+
18+
The script handles this step automatically. See `ec2-tags.sh` for the exact CLI commands.
19+
20+
## Step 4: Removing a tag
21+
22+
The script handles this step automatically. See `ec2-tags.sh` for the exact CLI commands.
23+
24+
## Cleanup
25+
26+
The script prompts you to clean up all created resources. If you need to clean up manually, check the script log for the resource names that were created.
27+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Lambda Destinations
2+
3+
An AWS CLI tutorial that demonstrates Iam operations.
4+
5+
## Running
6+
7+
```bash
8+
bash lambda-destinations.sh
9+
```
10+
11+
To auto-run with cleanup:
12+
13+
```bash
14+
echo 'y' | bash lambda-destinations.sh
15+
```
16+
17+
## What it does
18+
19+
1. Creating roles and functions"; RID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); R="dest-role-$RID"; Q="dest-queue-$RID"; F="dest-func-$RID"; ROLE_ARN=$(aws iam create-role --role-name "$R" --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}' --query Role.Arn --output text); aws iam attach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole; aws iam attach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/AmazonSQSFullAccess; sleep 10; QU=$(aws sqs create-queue --queue-name "$Q" --query QueueUrl --output text); QA=$(aws sqs get-queue-attributes --queue-url "$QU" --attribute-names QueueArn --query Attributes.QueueArn --output text); D=$(mktemp -d); echo "def handler(e,c): return {\"result\":\"success\"}" > "$D/i.py"; (cd "$D" && zip f.zip i.py > /dev/null); aws lambda create-function --function-name "$F" --zip-file "fileb://$D/f.zip" --handler i.handler --runtime python3.12 --role "$ROLE_ARN" --architectures x86_64 > /dev/null; aws lambda wait function-active-v2 --function-name "$F"; echo "Step 2: Configuring on-success destination"; aws lambda put-function-event-invoke-config --function-name "$F" --destination-config "{\"OnSuccess\":{\"Destination\":\"$QA\"}}" > /dev/null; echo " On-success -> SQS queue"; echo "Step 3: Invoking async"; aws lambda invoke --function-name "$F" --invocation-type Event --cli-binary-format raw-in-base64-out --payload '{}' "$D/out.json" > /dev/null; echo " Invoked async"; sleep 10; echo "Step 4: Checking SQS for result"; aws sqs receive-message --queue-url "$QU" --max-number-of-messages 1 --wait-time-seconds 5 --query "Messages[0].Body" --output text 2>/dev/null | python3 -c "import sys,json;d=json.loads(sys.stdin.read());print(f\" Result: {d.get('requestPayload',{})}\n Response: {d.get('responsePayload',{})}\")" 2>/dev/null || echo " No message yet"; echo "Do you want to clean up? (y/n): "; read -r C; [[ "$C" =~ ^[Yy]$ ]] && { aws lambda delete-function --function-name "$F" 2>/dev/null; aws sqs delete-queue --queue-url "$QU" 2>/dev/null; aws iam detach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole 2>/dev/null; aws iam detach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/AmazonSQSFullAccess 2>/dev/null; aws iam delete-role --role-name "$R" 2>/dev/null; rm -rf "$D
20+
21+
## Resources created
22+
23+
- Function
24+
- Queue
25+
- Role
26+
- Function Event Invoke Config
27+
28+
The script prompts you to clean up resources when it finishes.
29+
30+
## Cost
31+
32+
Free tier eligible for most operations. Clean up resources after use to avoid charges.
33+
34+
## Related docs
35+
36+
- [AWS CLI iam reference](https://docs.aws.amazon.com/cli/latest/reference/iam/index.html)
37+
- [AWS CLI lambda reference](https://docs.aws.amazon.com/cli/latest/reference/lambda/index.html)
38+
- [AWS CLI sqs reference](https://docs.aws.amazon.com/cli/latest/reference/sqs/index.html)
39+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Lambda Destinations
2+
3+
## Prerequisites
4+
5+
1. AWS CLI installed and configured (`aws configure`)
6+
2. Appropriate IAM permissions for the AWS services used
7+
8+
## Step 1: Creating roles and functions"; RID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); R="dest-role-$RID"; Q="dest-queue-$RID"; F="dest-func-$RID"; ROLE_ARN=$(aws iam create-role --role-name "$R" --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}' --query Role.Arn --output text); aws iam attach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole; aws iam attach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/AmazonSQSFullAccess; sleep 10; QU=$(aws sqs create-queue --queue-name "$Q" --query QueueUrl --output text); QA=$(aws sqs get-queue-attributes --queue-url "$QU" --attribute-names QueueArn --query Attributes.QueueArn --output text); D=$(mktemp -d); echo "def handler(e,c): return {\"result\":\"success\"}" > "$D/i.py"; (cd "$D" && zip f.zip i.py > /dev/null); aws lambda create-function --function-name "$F" --zip-file "fileb://$D/f.zip" --handler i.handler --runtime python3.12 --role "$ROLE_ARN" --architectures x86_64 > /dev/null; aws lambda wait function-active-v2 --function-name "$F"; echo "Step 2: Configuring on-success destination"; aws lambda put-function-event-invoke-config --function-name "$F" --destination-config "{\"OnSuccess\":{\"Destination\":\"$QA\"}}" > /dev/null; echo " On-success -> SQS queue"; echo "Step 3: Invoking async"; aws lambda invoke --function-name "$F" --invocation-type Event --cli-binary-format raw-in-base64-out --payload '{}' "$D/out.json" > /dev/null; echo " Invoked async"; sleep 10; echo "Step 4: Checking SQS for result"; aws sqs receive-message --queue-url "$QU" --max-number-of-messages 1 --wait-time-seconds 5 --query "Messages[0].Body" --output text 2>/dev/null | python3 -c "import sys,json;d=json.loads(sys.stdin.read());print(f\" Result: {d.get('requestPayload',{})}\n Response: {d.get('responsePayload',{})}\")" 2>/dev/null || echo " No message yet"; echo "Do you want to clean up? (y/n): "; read -r C; [[ "$C" =~ ^[Yy]$ ]] && { aws lambda delete-function --function-name "$F" 2>/dev/null; aws sqs delete-queue --queue-url "$QU" 2>/dev/null; aws iam detach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole 2>/dev/null; aws iam detach-role-policy --role-name "$R" --policy-arn arn:aws:iam::aws:policy/AmazonSQSFullAccess 2>/dev/null; aws iam delete-role --role-name "$R" 2>/dev/null; rm -rf "$D
9+
10+
The script handles this step automatically. See `lambda-destinations.sh` for the exact CLI commands.
11+
12+
## Cleanup
13+
14+
The script prompts you to clean up all created resources. If you need to clean up manually, check the script log for the resource names that were created.
15+

tuts/178-ec2-amis/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Ec2 Amis
2+
3+
A read-only script that queries Ec2 resources and displays information.
4+
5+
## Running
6+
7+
```bash
8+
bash ec2-amis.sh
9+
```
10+
11+
## What it does
12+
13+
1. Listing Amazon Linux 2023 AMIs
14+
2. Listing Ubuntu AMIs
15+
3. Describing a specific AMI
16+
4. Listing your own AMIs
17+
18+
## Resources created
19+
20+
None — this script is read-only.
21+
22+
## Cost
23+
24+
No cost. This script only reads existing resources.
25+
26+
## Related docs
27+
28+
- [AWS CLI ec2 reference](https://docs.aws.amazon.com/cli/latest/reference/ec2/index.html)
29+

tuts/178-ec2-amis/ec2-amis.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Ec2 Amis
2+
3+
## Prerequisites
4+
5+
1. AWS CLI installed and configured (`aws configure`)
6+
2. Appropriate IAM permissions for the AWS services used
7+
8+
## Step 1: Listing Amazon Linux 2023 AMIs
9+
10+
The script handles this step automatically. See `ec2-amis.sh` for the exact CLI commands.
11+
12+
## Step 2: Listing Ubuntu AMIs
13+
14+
The script handles this step automatically. See `ec2-amis.sh` for the exact CLI commands.
15+
16+
## Step 3: Describing a specific AMI
17+
18+
The script handles this step automatically. See `ec2-amis.sh` for the exact CLI commands.
19+
20+
## Step 4: Listing your own AMIs
21+
22+
The script handles this step automatically. See `ec2-amis.sh` for the exact CLI commands.
23+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Ec2 Placement Groups
2+
3+
An AWS CLI tutorial that demonstrates Ec2 operations.
4+
5+
## Running
6+
7+
```bash
8+
bash ec2-placement-groups.sh
9+
```
10+
11+
To auto-run with cleanup:
12+
13+
```bash
14+
echo 'y' | bash ec2-placement-groups.sh
15+
```
16+
17+
## What it does
18+
19+
1. Creating cluster placement group
20+
2. Creating spread placement group
21+
3. Describing placement groups
22+
23+
## Resources created
24+
25+
- Placement Group
26+
27+
The script prompts you to clean up resources when it finishes.
28+
29+
## Cost
30+
31+
Free tier eligible for most operations. Clean up resources after use to avoid charges.
32+
33+
## Related docs
34+
35+
- [AWS CLI ec2 reference](https://docs.aws.amazon.com/cli/latest/reference/ec2/index.html)
36+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Ec2 Placement Groups
2+
3+
## Prerequisites
4+
5+
1. AWS CLI installed and configured (`aws configure`)
6+
2. Appropriate IAM permissions for the AWS services used
7+
8+
## Step 1: Creating cluster placement group
9+
10+
The script handles this step automatically. See `ec2-placement-groups.sh` for the exact CLI commands.
11+
12+
## Step 2: Creating spread placement group
13+
14+
The script handles this step automatically. See `ec2-placement-groups.sh` for the exact CLI commands.
15+
16+
## Step 3: Describing placement groups
17+
18+
The script handles this step automatically. See `ec2-placement-groups.sh` for the exact CLI commands.
19+
20+
## Cleanup
21+
22+
The script prompts you to clean up all created resources. If you need to clean up manually, check the script log for the resource names that were created.
23+

0 commit comments

Comments
 (0)