From e0ae46e392b36b04a82ed129359700b6efc3f323 Mon Sep 17 00:00:00 2001 From: Michael Wunderlich Date: Tue, 14 Apr 2026 16:35:00 +0000 Subject: [PATCH 1/3] Add developer-tools tutorials (batch 15) --- tuts/096-aws-codecommit-gs/README.md | 64 ++++++++ .../aws-codecommit-gs.md | 108 ++++++++++++++ .../aws-codecommit-gs.sh | 100 +++++++++++++ tuts/098-aws-codebuild-gs/README.md | 65 +++++++++ tuts/098-aws-codebuild-gs/aws-codebuild-gs.md | 131 +++++++++++++++++ tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh | 138 ++++++++++++++++++ .../aws-codeartifact-gs.sh | 30 ++++ .../aws-codedeploy-gs.sh | 14 ++ .../aws-codepipeline-gs.sh | 22 +++ 9 files changed, 672 insertions(+) create mode 100644 tuts/096-aws-codecommit-gs/README.md create mode 100644 tuts/096-aws-codecommit-gs/aws-codecommit-gs.md create mode 100644 tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh create mode 100644 tuts/098-aws-codebuild-gs/README.md create mode 100644 tuts/098-aws-codebuild-gs/aws-codebuild-gs.md create mode 100644 tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh create mode 100644 tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh create mode 100644 tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh create mode 100644 tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh diff --git a/tuts/096-aws-codecommit-gs/README.md b/tuts/096-aws-codecommit-gs/README.md new file mode 100644 index 00000000..e9ad6554 --- /dev/null +++ b/tuts/096-aws-codecommit-gs/README.md @@ -0,0 +1,64 @@ +# CodeCommit: Create a repository and manage code + +Create a CodeCommit repository, add files, branch, compare changes, and retrieve metadata using the AWS CLI. + +## Source + +https://docs.aws.amazon.com/codecommit/latest/userguide/getting-started-cc.html + +## Use case + +- ID: codecommit/getting-started +- Phase: create +- Complexity: beginner +- Core actions: codecommit:CreateRepository, codecommit:PutFile, codecommit:CreateBranch + +## What it does + +1. Creates a CodeCommit repository +2. Adds a file using fileb:// +3. Retrieves the file metadata +4. Creates a feature branch +5. Adds a file to the feature branch +6. Compares branches with get-differences +7. Gets repository metadata + +## Running + +```bash +bash aws-codecommit-gs.sh +``` + +## Resources created + +- CodeCommit repository + +No persistent resources remain after cleanup. The script prompts you to delete the repository when it finishes. + +## Estimated time + +- Run: ~11 seconds + +## Cost + +CodeCommit is free for up to 5 active users per month (unlimited repositories). No charges for this tutorial under the free tier. + +## Related docs + +- [Getting started with CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/getting-started-cc.html) +- [put-file CLI reference](https://docs.aws.amazon.com/cli/latest/reference/codecommit/put-file.html) +- [Working with branches](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-branch.html) +- [CodeCommit quotas](https://docs.aws.amazon.com/codecommit/latest/userguide/limits.html) +- [CodeCommit pricing](https://aws.amazon.com/codecommit/pricing/) + +--- + +## Appendix: Generation details + +| Field | Value | +|-------|-------| +| Generation date | 2026-04-14 | +| Source script | New, 100 lines | +| Script test result | EXIT 0, 11s, 7 steps, no issues | +| Issues encountered | file-content needs fileb:// not inline string (fixed) | +| Iterations | v1 | diff --git a/tuts/096-aws-codecommit-gs/aws-codecommit-gs.md b/tuts/096-aws-codecommit-gs/aws-codecommit-gs.md new file mode 100644 index 00000000..eb481188 --- /dev/null +++ b/tuts/096-aws-codecommit-gs/aws-codecommit-gs.md @@ -0,0 +1,108 @@ +# Create a CodeCommit repository and manage code + +This tutorial shows you how to create a CodeCommit repository, add files, create a branch, compare changes between branches, and retrieve repository metadata using the AWS CLI. + +## Prerequisites + +- AWS CLI configured with credentials and a default region +- Permissions for `codecommit:CreateRepository`, `codecommit:PutFile`, `codecommit:GetFile`, `codecommit:CreateBranch`, `codecommit:ListBranches`, `codecommit:GetDifferences`, `codecommit:GetRepository`, `codecommit:DeleteRepository` + +## Step 1: Create a repository + +```bash +aws codecommit create-repository --repository-name "$REPO_NAME" \ + --repository-description "Tutorial repository" \ + --query 'repositoryMetadata.{Name:repositoryName,Id:repositoryId}' --output table +``` + +CodeCommit returns the repository metadata including the name and unique ID. + +## Step 2: Add a file + +Write a file locally and upload it with `put-file`. Use `fileb://` to pass the file content as raw bytes: + +```bash +echo -e "# Tutorial Repository\n\nThis is a sample file." > "$WORK_DIR/README.md" +COMMIT_ID=$(aws codecommit put-file \ + --repository-name "$REPO_NAME" \ + --branch-name main \ + --file-content "fileb://$WORK_DIR/README.md" \ + --file-path README.md \ + --commit-message "Initial commit" \ + --name "Tutorial User" \ + --email "tutorial@example.com" \ + --query 'commitId' --output text) +``` + +The `fileb://` prefix tells the CLI to read the file as raw binary. This creates the `main` branch with the first commit. + +## Step 3: Get the file + +Retrieve file metadata from the repository: + +```bash +aws codecommit get-file --repository-name "$REPO_NAME" \ + --file-path README.md \ + --query '{Path:filePath,Size:fileSize,CommitId:commitId}' --output table +``` + +## Step 4: Create a branch + +Create a branch from the current commit and list all branches: + +```bash +aws codecommit create-branch --repository-name "$REPO_NAME" \ + --branch-name feature-branch --commit-id "$COMMIT_ID" +aws codecommit list-branches --repository-name "$REPO_NAME" \ + --query 'branches' --output table +``` + +## Step 5: Add a file to the branch + +Add a new file to the feature branch. Pass `--parent-commit-id` to build on the branch tip: + +```bash +echo "console.log('Hello from CodeCommit');" > "$WORK_DIR/index.js" +aws codecommit put-file \ + --repository-name "$REPO_NAME" \ + --branch-name feature-branch \ + --file-content "fileb://$WORK_DIR/index.js" \ + --file-path src/index.js \ + --commit-message "Add source file" \ + --parent-commit-id "$COMMIT_ID" \ + --query 'commitId' --output text +``` + +## Step 6: Compare branches + +Use `get-differences` to see what changed between `main` and `feature-branch`: + +```bash +aws codecommit get-differences \ + --repository-name "$REPO_NAME" \ + --before-commit-specifier main \ + --after-commit-specifier feature-branch \ + --query 'differences[].{Path:afterBlob.path,Type:changeType}' --output table +``` + +## Step 7: Get repository metadata + +```bash +aws codecommit get-repository --repository-name "$REPO_NAME" \ + --query 'repositoryMetadata.{Name:repositoryName,DefaultBranch:defaultBranch,Created:creationDate}' \ + --output table +``` + +## Cleanup + +Delete the repository. This removes all branches, files, and commit history: + +```bash +aws codecommit delete-repository --repository-name "$REPO_NAME" +``` + +The script automates all steps including cleanup: + +```bash +bash aws-codecommit-gs.sh +``` diff --git a/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh b/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh new file mode 100644 index 00000000..f88c5002 --- /dev/null +++ b/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# Tutorial: Create a CodeCommit repository and manage code +# Source: https://docs.aws.amazon.com/codecommit/latest/userguide/getting-started-cc.html + +WORK_DIR=$(mktemp -d) +LOG_FILE="$WORK_DIR/codecommit-$(date +%Y%m%d-%H%M%S).log" +exec > >(tee -a "$LOG_FILE") 2>&1 + +REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null)}} +if [ -z "$REGION" ]; then + echo "ERROR: No AWS region configured. Set one with: export AWS_DEFAULT_REGION=us-east-1" + exit 1 +fi +export AWS_DEFAULT_REGION="$REGION" +echo "Region: $REGION" + +RANDOM_ID=$(openssl rand -hex 4) +REPO_NAME="tutorial-repo-${RANDOM_ID}" + +handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; } +trap 'handle_error $LINENO' ERR + +cleanup() { + echo "" + echo "Cleaning up resources..." + aws codecommit delete-repository --repository-name "$REPO_NAME" > /dev/null 2>&1 && \ + echo " Deleted repository $REPO_NAME" + rm -rf "$WORK_DIR" + echo "Cleanup complete." +} + +# Step 1: Create a repository +echo "Step 1: Creating repository: $REPO_NAME" +aws codecommit create-repository --repository-name "$REPO_NAME" \ + --repository-description "Tutorial repository" \ + --query 'repositoryMetadata.{Name:repositoryName,Id:repositoryId}' --output table + +# Step 2: Add a file +echo "Step 2: Adding a file to the repository" +echo -e "# Tutorial Repository\n\nThis is a sample file created by the CodeCommit tutorial." > "$WORK_DIR/README.md" +COMMIT_ID=$(aws codecommit put-file \ + --repository-name "$REPO_NAME" \ + --branch-name main \ + --file-content "fileb://$WORK_DIR/README.md" \ + --file-path README.md \ + --commit-message "Initial commit" \ + --name "Tutorial User" \ + --email "tutorial@example.com" \ + --query 'commitId' --output text) +echo " Commit: $COMMIT_ID" + +# Step 3: Get the file +echo "Step 3: Retrieving the file" +aws codecommit get-file --repository-name "$REPO_NAME" \ + --file-path README.md \ + --query '{Path:filePath,Size:fileSize,CommitId:commitId}' --output table + +# Step 4: Create a branch +echo "Step 4: Creating a branch" +aws codecommit create-branch --repository-name "$REPO_NAME" \ + --branch-name feature-branch --commit-id "$COMMIT_ID" +aws codecommit list-branches --repository-name "$REPO_NAME" \ + --query 'branches' --output table + +# Step 5: Add a file to the branch +echo "Step 5: Adding a file to the feature branch" +echo "console.log('Hello from CodeCommit');" > "$WORK_DIR/index.js" +aws codecommit put-file \ + --repository-name "$REPO_NAME" \ + --branch-name feature-branch \ + --file-content "fileb://$WORK_DIR/index.js" \ + --file-path src/index.js \ + --commit-message "Add source file" \ + --parent-commit-id "$COMMIT_ID" \ + --query 'commitId' --output text > /dev/null +echo " File added to feature-branch" + +# Step 6: Get differences between branches +echo "Step 6: Comparing branches" +aws codecommit get-differences \ + --repository-name "$REPO_NAME" \ + --before-commit-specifier main \ + --after-commit-specifier feature-branch \ + --query 'differences[].{Path:afterBlob.path,Type:changeType}' --output table + +# Step 7: Get repository metadata +echo "Step 7: Repository metadata" +aws codecommit get-repository --repository-name "$REPO_NAME" \ + --query 'repositoryMetadata.{Name:repositoryName,DefaultBranch:defaultBranch,Created:creationDate}' --output table + +echo "" +echo "Tutorial complete." +echo "Do you want to clean up all resources? (y/n): " +read -r CHOICE +if [[ "$CHOICE" =~ ^[Yy]$ ]]; then + cleanup +else + echo "Manual cleanup:" + echo " aws codecommit delete-repository --repository-name $REPO_NAME" +fi diff --git a/tuts/098-aws-codebuild-gs/README.md b/tuts/098-aws-codebuild-gs/README.md new file mode 100644 index 00000000..b0b1f8d3 --- /dev/null +++ b/tuts/098-aws-codebuild-gs/README.md @@ -0,0 +1,65 @@ +# CodeBuild: Create a project and run a build + +Create an S3-sourced CodeBuild project, run a build, and verify artifacts using the AWS CLI. + +## Source + +https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-cli.html + +## Use case + +- ID: codebuild/getting-started +- Phase: create +- Complexity: intermediate +- Core actions: codebuild:CreateProject, codebuild:StartBuild + +## What it does + +1. Creates an S3 bucket for source and artifacts +2. Creates source files (buildspec.yml + index.html) and uploads as zip +3. Creates an IAM service role for CodeBuild +4. Creates a build project with S3 source +5. Starts a build +6. Waits for completion and checks artifacts + +## Running + +```bash +bash aws-codebuild-gs.sh +``` + +## Resources created + +- S3 bucket (source and artifacts) +- CodeBuild project +- IAM role (with S3 and CloudWatch Logs policies) +- CloudWatch log group (created automatically by CodeBuild) + +No persistent resources remain after cleanup. The script prompts you to delete all resources when it finishes. + +## Estimated time + +- Run: ~37 seconds (includes build execution) + +## Cost + +CodeBuild free tier includes 100 build minutes per month on general1.small. No charges expected for this tutorial under the free tier. + +## Related docs + +- [Getting started with CodeBuild (CLI)](https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-cli.html) +- [Build specification reference](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) +- [Build environment reference](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html) +- [CodeBuild pricing](https://aws.amazon.com/codebuild/pricing/) + +--- + +## Appendix: Generation details + +| Field | Value | +|-------|-------| +| Generation date | 2026-04-14 | +| Source script | New, 138 lines | +| Script test result | EXIT 0, 37s, 6 steps, no issues | +| Issues encountered | None | +| Iterations | v1 | diff --git a/tuts/098-aws-codebuild-gs/aws-codebuild-gs.md b/tuts/098-aws-codebuild-gs/aws-codebuild-gs.md new file mode 100644 index 00000000..7dbc0a29 --- /dev/null +++ b/tuts/098-aws-codebuild-gs/aws-codebuild-gs.md @@ -0,0 +1,131 @@ +# Create a build project and run a build with AWS CodeBuild + +This tutorial shows you how to create an S3 bucket for source and artifacts, create source files, configure an IAM role, create a CodeBuild project, run a build, and verify the output. + +## Prerequisites + +- AWS CLI configured with credentials and a default region +- Permissions for `codebuild:CreateProject`, `codebuild:StartBuild`, `codebuild:BatchGetBuilds`, `codebuild:DeleteProject`, `s3:CreateBucket`, `s3:PutObject`, `s3:GetObject`, `iam:CreateRole`, `iam:AttachRolePolicy`, `iam:PutRolePolicy`, `iam:DeleteRole` + +## Step 1: Create an S3 bucket + +Create a bucket to hold the build source and output artifacts: + +```bash +BUCKET_NAME="codebuild-tut-${RANDOM_ID}-${ACCOUNT_ID}" +aws s3api create-bucket --bucket "$BUCKET_NAME" \ + --create-bucket-configuration LocationConstraint="$REGION" +``` + +For `us-east-1`, omit the `--create-bucket-configuration` parameter. + +## Step 2: Create source files and upload + +Create a `buildspec.yml` that defines the build commands and an `index.html` as sample content. Package them into a zip and upload to S3: + +```bash +cat > buildspec.yml << 'EOF' +version: 0.2 +phases: + build: + commands: + - echo "Build started on $(date)" + - echo "Hello from CodeBuild" + - echo "Build completed" +artifacts: + files: + - '**/*' +EOF + +cat > index.html << 'EOF' +

Built by CodeBuild

+EOF + +zip source.zip buildspec.yml index.html +aws s3 cp source.zip "s3://$BUCKET_NAME/source.zip" +``` + +The `buildspec.yml` tells CodeBuild what commands to run and which files to include in the output artifacts. + +## Step 3: Create an IAM role for CodeBuild + +Create a service role that allows CodeBuild to access S3 and write logs: + +```bash +ROLE_ARN=$(aws iam create-role --role-name "$ROLE_NAME" \ + --assume-role-policy-document '{ + "Version":"2012-10-17", + "Statement":[{"Effect":"Allow","Principal":{"Service":"codebuild.amazonaws.com"},"Action":"sts:AssumeRole"}] + }' --query 'Role.Arn' --output text) + +aws iam attach-role-policy --role-name "$ROLE_NAME" \ + --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess + +aws iam put-role-policy --role-name "$ROLE_NAME" --policy-name codebuild-logs \ + --policy-document '{ + "Version":"2012-10-17", + "Statement":[{"Effect":"Allow","Action":["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],"Resource":"*"}] + }' +``` + +Wait about 10 seconds for the role to propagate before using it. + +## Step 4: Create a build project + +Create a project that reads source from S3 and writes artifacts back to S3: + +```bash +aws codebuild create-project \ + --name "$PROJECT_NAME" \ + --source "type=S3,location=$BUCKET_NAME/source.zip" \ + --artifacts "type=S3,location=$BUCKET_NAME,path=output" \ + --environment "type=LINUX_CONTAINER,computeType=BUILD_GENERAL1_SMALL,image=aws/codebuild/amazonlinux-x86_64-standard:5.0" \ + --service-role "$ROLE_ARN" \ + --query 'project.{Name:name,Created:created}' --output table +``` + +The environment uses a managed Amazon Linux image with standard build tools. + +## Step 5: Start a build + +```bash +BUILD_ID=$(aws codebuild start-build --project-name "$PROJECT_NAME" \ + --query 'build.id' --output text) +echo "Build ID: $BUILD_ID" +``` + +## Step 6: Wait for build completion and check artifacts + +Poll the build status until it completes: + +```bash +STATUS=$(aws codebuild batch-get-builds --ids "$BUILD_ID" \ + --query 'builds[0].buildStatus' --output text) +``` + +When the status is `SUCCEEDED`, list the output artifacts: + +```bash +aws s3 ls "s3://$BUCKET_NAME/output/" --recursive +``` + +## Cleanup + +Delete the build project, empty and remove the S3 bucket, detach policies and delete the IAM role, and delete the CloudWatch log group: + +```bash +aws codebuild delete-project --name "$PROJECT_NAME" +aws s3 rm "s3://$BUCKET_NAME" --recursive +aws s3 rb "s3://$BUCKET_NAME" +aws iam detach-role-policy --role-name "$ROLE_NAME" \ + --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess +aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name codebuild-logs +aws iam delete-role --role-name "$ROLE_NAME" +aws logs delete-log-group --log-group-name "/aws/codebuild/$PROJECT_NAME" +``` + +The script automates all steps including cleanup: + +```bash +bash aws-codebuild-gs.sh +``` diff --git a/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh b/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh new file mode 100644 index 00000000..87094324 --- /dev/null +++ b/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# Tutorial: Create a build project and run a build with AWS CodeBuild +# Source: https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-cli.html + +WORK_DIR=$(mktemp -d) +LOG_FILE="$WORK_DIR/codebuild-$(date +%Y%m%d-%H%M%S).log" +exec > >(tee -a "$LOG_FILE") 2>&1 + +REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null)}} +if [ -z "$REGION" ]; then + echo "ERROR: No AWS region configured. Set one with: export AWS_DEFAULT_REGION=us-east-1" + exit 1 +fi +export AWS_DEFAULT_REGION="$REGION" +ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text) +echo "Region: $REGION" + +RANDOM_ID=$(openssl rand -hex 4) +BUCKET_NAME="codebuild-tut-${RANDOM_ID}-${ACCOUNT_ID}" +PROJECT_NAME="tut-build-${RANDOM_ID}" +ROLE_NAME="codebuild-tut-role-${RANDOM_ID}" + +handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; } +trap 'handle_error $LINENO' ERR + +cleanup() { + echo "" + echo "Cleaning up resources..." + aws codebuild delete-project --name "$PROJECT_NAME" 2>/dev/null && echo " Deleted project $PROJECT_NAME" + if aws s3 ls "s3://$BUCKET_NAME" > /dev/null 2>&1; then + aws s3 rm "s3://$BUCKET_NAME" --recursive --quiet 2>/dev/null + aws s3 rb "s3://$BUCKET_NAME" 2>/dev/null && echo " Deleted bucket $BUCKET_NAME" + fi + aws iam detach-role-policy --role-name "$ROLE_NAME" \ + --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess 2>/dev/null + aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name codebuild-logs 2>/dev/null + aws iam delete-role --role-name "$ROLE_NAME" 2>/dev/null && echo " Deleted role $ROLE_NAME" + aws logs delete-log-group --log-group-name "/aws/codebuild/$PROJECT_NAME" 2>/dev/null && echo " Deleted log group" + rm -rf "$WORK_DIR" + echo "Cleanup complete." +} + +# Step 1: Create S3 bucket for build artifacts +echo "Step 1: Creating S3 bucket: $BUCKET_NAME" +if [ "$REGION" = "us-east-1" ]; then + aws s3api create-bucket --bucket "$BUCKET_NAME" > /dev/null +else + aws s3api create-bucket --bucket "$BUCKET_NAME" \ + --create-bucket-configuration LocationConstraint="$REGION" > /dev/null +fi + +# Step 2: Create source files and upload +echo "Step 2: Creating source files" +mkdir -p "$WORK_DIR/src" +cat > "$WORK_DIR/src/buildspec.yml" << 'EOF' +version: 0.2 +phases: + build: + commands: + - echo "Build started on $(date)" + - echo "Hello from CodeBuild" + - echo "Build completed" +artifacts: + files: + - '**/*' +EOF +cat > "$WORK_DIR/src/index.html" << 'EOF' +

Built by CodeBuild

+EOF +(cd "$WORK_DIR/src" && zip -r "$WORK_DIR/source.zip" . > /dev/null) +aws s3 cp "$WORK_DIR/source.zip" "s3://$BUCKET_NAME/source.zip" --quiet +echo " Source uploaded to s3://$BUCKET_NAME/source.zip" + +# Step 3: Create IAM role for CodeBuild +echo "Step 3: Creating IAM role: $ROLE_NAME" +ROLE_ARN=$(aws iam create-role --role-name "$ROLE_NAME" \ + --assume-role-policy-document '{ + "Version":"2012-10-17", + "Statement":[{"Effect":"Allow","Principal":{"Service":"codebuild.amazonaws.com"},"Action":"sts:AssumeRole"}] + }' --query 'Role.Arn' --output text) +aws iam attach-role-policy --role-name "$ROLE_NAME" \ + --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess +aws iam put-role-policy --role-name "$ROLE_NAME" --policy-name codebuild-logs \ + --policy-document '{ + "Version":"2012-10-17", + "Statement":[{"Effect":"Allow","Action":["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],"Resource":"*"}] + }' +echo " Role ARN: $ROLE_ARN" +sleep 10 + +# Step 4: Create build project +echo "Step 4: Creating build project: $PROJECT_NAME" +aws codebuild create-project \ + --name "$PROJECT_NAME" \ + --source "type=S3,location=$BUCKET_NAME/source.zip" \ + --artifacts "type=S3,location=$BUCKET_NAME,path=output" \ + --environment "type=LINUX_CONTAINER,computeType=BUILD_GENERAL1_SMALL,image=aws/codebuild/amazonlinux-x86_64-standard:5.0" \ + --service-role "$ROLE_ARN" \ + --query 'project.{Name:name,Created:created}' --output table + +# Step 5: Start a build +echo "Step 5: Starting build" +BUILD_ID=$(aws codebuild start-build --project-name "$PROJECT_NAME" \ + --query 'build.id' --output text) +echo " Build ID: $BUILD_ID" + +# Step 6: Wait for build to complete +echo "Step 6: Waiting for build to complete..." +for i in $(seq 1 30); do + STATUS=$(aws codebuild batch-get-builds --ids "$BUILD_ID" \ + --query 'builds[0].buildStatus' --output text) + echo " Status: $STATUS" + [ "$STATUS" = "SUCCEEDED" ] || [ "$STATUS" = "FAILED" ] || [ "$STATUS" = "STOPPED" ] && break + sleep 10 +done + +if [ "$STATUS" = "SUCCEEDED" ]; then + echo " Build succeeded!" + echo " Artifacts: s3://$BUCKET_NAME/output/" + aws s3 ls "s3://$BUCKET_NAME/output/" --recursive 2>/dev/null | head -5 +else + echo " Build did not succeed: $STATUS" +fi + +echo "" +echo "Tutorial complete." +echo "Do you want to clean up all resources? (y/n): " +read -r CHOICE +if [[ "$CHOICE" =~ ^[Yy]$ ]]; then + cleanup +else + echo "Manual cleanup:" + echo " aws codebuild delete-project --name $PROJECT_NAME" + echo " aws s3 rm s3://$BUCKET_NAME --recursive && aws s3 rb s3://$BUCKET_NAME" + echo " aws iam detach-role-policy --role-name $ROLE_NAME --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess" + echo " aws iam delete-role-policy --role-name $ROLE_NAME --policy-name codebuild-logs" + echo " aws iam delete-role --role-name $ROLE_NAME" +fi diff --git a/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh b/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh new file mode 100644 index 00000000..d2b54026 --- /dev/null +++ b/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh @@ -0,0 +1,30 @@ +#!/bin/bash +WORK_DIR=$(mktemp -d) +exec > >(tee -a "$WORK_DIR/codeartifact-$(date +%Y%m%d-%H%M%S).log") 2>&1 +REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)} +[ -z "$REGION" ] && echo "ERROR: No region" && exit 1 +export AWS_DEFAULT_REGION="$REGION" +ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text) +echo "Region: $REGION" +RANDOM_ID=$(openssl rand -hex 4) +DOMAIN="tut-domain-${RANDOM_ID}" +REPO="tut-repo-${RANDOM_ID}" +handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; } +trap 'handle_error $LINENO' ERR +cleanup() { echo ""; echo "Cleaning up..."; aws codeartifact delete-repository --domain "$DOMAIN" --repository "$REPO" > /dev/null 2>&1 && echo " Deleted repo"; aws codeartifact delete-domain --domain "$DOMAIN" > /dev/null 2>&1 && echo " Deleted domain"; rm -rf "$WORK_DIR"; echo "Done."; } +echo "Step 1: Creating domain: $DOMAIN" +aws codeartifact create-domain --domain "$DOMAIN" --query 'domain.{Name:name,Status:status}' --output table +echo "Step 2: Creating repository: $REPO" +aws codeartifact create-repository --domain "$DOMAIN" --repository "$REPO" --query 'repository.{Name:name,DomainName:domainName}' --output table +echo "Step 3: Getting authorization token" +TOKEN=$(aws codeartifact get-authorization-token --domain "$DOMAIN" --query 'authorizationToken' --output text) +echo " Token: ${TOKEN:0:20}..." +echo "Step 4: Getting repository endpoint" +aws codeartifact get-repository-endpoint --domain "$DOMAIN" --repository "$REPO" --format npm --query 'repositoryEndpoint' --output text +echo "Step 5: Listing repositories" +aws codeartifact list-repositories --query 'repositories[?starts_with(name, `tut-`)].{Name:name,Domain:domainName}' --output table +echo "" +echo "Tutorial complete." +echo "Do you want to clean up? (y/n): " +read -r CHOICE +[[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup || echo "Manual: aws codeartifact delete-repository --domain $DOMAIN --repository $REPO && aws codeartifact delete-domain --domain $DOMAIN" diff --git a/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh b/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh new file mode 100644 index 00000000..410c900d --- /dev/null +++ b/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh @@ -0,0 +1,14 @@ +#!/bin/bash +WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/codedeploy.log") 2>&1 +REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION" +RANDOM_ID=$(openssl rand -hex 4); APP_NAME="tut-app-${RANDOM_ID}" +handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR +cleanup() { echo ""; echo "Cleaning up..."; aws deploy delete-application --application-name "$APP_NAME" 2>/dev/null && echo " Deleted app"; rm -rf "$WORK_DIR"; echo "Done."; } +echo "Step 1: Creating application: $APP_NAME" +aws deploy create-application --application-name "$APP_NAME" --compute-platform Server --query 'applicationId' --output text +echo "Step 2: Listing applications" +aws deploy list-applications --query 'applications[?starts_with(@, `tut-`)]' --output table +echo "Step 3: Getting application details" +aws deploy get-application --application-name "$APP_NAME" --query 'application.{Name:applicationName,Id:applicationId,Created:createTime}' --output table +echo ""; echo "Tutorial complete." +echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup diff --git a/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh b/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh new file mode 100644 index 00000000..3526c2fe --- /dev/null +++ b/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh @@ -0,0 +1,22 @@ +#!/bin/bash +WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/codepipeline.log") 2>&1 +REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text); echo "Region: $REGION" +RANDOM_ID=$(openssl rand -hex 4); PIPE_NAME="tut-pipe-${RANDOM_ID}"; BUCKET="codepipeline-tut-${RANDOM_ID}-${ACCOUNT}"; ROLE_NAME="codepipeline-tut-role-${RANDOM_ID}" +handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR +cleanup() { echo ""; echo "Cleaning up..."; aws codepipeline delete-pipeline --name "$PIPE_NAME" 2>/dev/null && echo " Deleted pipeline"; aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name pipe-policy 2>/dev/null; aws iam delete-role --role-name "$ROLE_NAME" 2>/dev/null && echo " Deleted role"; if aws s3 ls "s3://$BUCKET" > /dev/null 2>&1; then aws s3 rm "s3://$BUCKET" --recursive --quiet; aws s3 rb "s3://$BUCKET" && echo " Deleted bucket"; fi; rm -rf "$WORK_DIR"; echo "Done."; } +echo "Step 1: Creating S3 bucket for artifacts" +if [ "$REGION" = "us-east-1" ]; then aws s3api create-bucket --bucket "$BUCKET" > /dev/null; else aws s3api create-bucket --bucket "$BUCKET" --create-bucket-configuration LocationConstraint="$REGION" > /dev/null; fi +echo " Bucket: $BUCKET" +echo "Step 2: Creating IAM role" +ROLE_ARN=$(aws iam create-role --role-name "$ROLE_NAME" --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"codepipeline.amazonaws.com"},"Action":"sts:AssumeRole"}]}' --query 'Role.Arn' --output text) +aws iam put-role-policy --role-name "$ROLE_NAME" --policy-name pipe-policy --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:*","codebuild:*","codecommit:*"],"Resource":"*"}]}' +echo " Role: $ROLE_ARN"; sleep 10 +echo "Step 3: Creating pipeline: $PIPE_NAME" +aws codepipeline create-pipeline --pipeline "{\"name\":\"$PIPE_NAME\",\"roleArn\":\"$ROLE_ARN\",\"artifactStore\":{\"type\":\"S3\",\"location\":\"$BUCKET\"},\"stages\":[{\"name\":\"Source\",\"actions\":[{\"name\":\"S3Source\",\"actionTypeId\":{\"category\":\"Source\",\"owner\":\"AWS\",\"provider\":\"S3\",\"version\":\"1\"},\"configuration\":{\"S3Bucket\":\"$BUCKET\",\"S3ObjectKey\":\"source.zip\",\"PollForSourceChanges\":\"false\"},\"outputArtifacts\":[{\"name\":\"SourceOutput\"}]}]},{\"name\":\"Deploy\",\"actions\":[{\"name\":\"S3Deploy\",\"actionTypeId\":{\"category\":\"Deploy\",\"owner\":\"AWS\",\"provider\":\"S3\",\"version\":\"1\"},\"configuration\":{\"BucketName\":\"$BUCKET\",\"Extract\":\"true\"},\"inputArtifacts\":[{\"name\":\"SourceOutput\"}]}]}]}" --query 'pipeline.name' --output text > /dev/null +echo " Pipeline created" +echo "Step 4: Getting pipeline state" +aws codepipeline get-pipeline-state --name "$PIPE_NAME" --query 'stageStates[].{Stage:stageName,Status:latestExecution.status}' --output table 2>/dev/null || echo " No executions yet" +echo "Step 5: Listing pipelines" +aws codepipeline list-pipelines --query 'pipelines[?starts_with(name, `tut-`)].{Name:name,Created:created}' --output table +echo ""; echo "Tutorial complete." +echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup From 88e07e8a3e0393cc97528a31683b5475aa5cd7b8 Mon Sep 17 00:00:00 2001 From: Michael Wunderlich Date: Tue, 21 Apr 2026 05:17:16 +0000 Subject: [PATCH 2/3] Apply technical requirements (R1, R2, R9, R10, R13) - R1: Add AWS_REGION to region fallback chain - R2: Replace openssl rand with /dev/urandom - R9: Remove Appendix/Generation details from READMEs - R10: Remove internal references - R13: Add REVISION-HISTORY.md --- tuts/096-aws-codecommit-gs/README.md | 12 ------------ tuts/096-aws-codecommit-gs/REVISION-HISTORY.md | 8 ++++++++ tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh | 2 +- tuts/098-aws-codebuild-gs/README.md | 12 ------------ tuts/098-aws-codebuild-gs/REVISION-HISTORY.md | 8 ++++++++ tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh | 2 +- tuts/125-aws-codeartifact-gs/REVISION-HISTORY.md | 8 ++++++++ tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh | 4 ++-- tuts/135-aws-codedeploy-gs/REVISION-HISTORY.md | 8 ++++++++ tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh | 4 ++-- tuts/136-aws-codepipeline-gs/REVISION-HISTORY.md | 8 ++++++++ tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh | 4 ++-- 12 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 tuts/096-aws-codecommit-gs/REVISION-HISTORY.md create mode 100644 tuts/098-aws-codebuild-gs/REVISION-HISTORY.md create mode 100644 tuts/125-aws-codeartifact-gs/REVISION-HISTORY.md create mode 100644 tuts/135-aws-codedeploy-gs/REVISION-HISTORY.md create mode 100644 tuts/136-aws-codepipeline-gs/REVISION-HISTORY.md diff --git a/tuts/096-aws-codecommit-gs/README.md b/tuts/096-aws-codecommit-gs/README.md index e9ad6554..baed7890 100644 --- a/tuts/096-aws-codecommit-gs/README.md +++ b/tuts/096-aws-codecommit-gs/README.md @@ -50,15 +50,3 @@ CodeCommit is free for up to 5 active users per month (unlimited repositories). - [Working with branches](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-branch.html) - [CodeCommit quotas](https://docs.aws.amazon.com/codecommit/latest/userguide/limits.html) - [CodeCommit pricing](https://aws.amazon.com/codecommit/pricing/) - ---- - -## Appendix: Generation details - -| Field | Value | -|-------|-------| -| Generation date | 2026-04-14 | -| Source script | New, 100 lines | -| Script test result | EXIT 0, 11s, 7 steps, no issues | -| Issues encountered | file-content needs fileb:// not inline string (fixed) | -| Iterations | v1 | diff --git a/tuts/096-aws-codecommit-gs/REVISION-HISTORY.md b/tuts/096-aws-codecommit-gs/REVISION-HISTORY.md new file mode 100644 index 00000000..787c0744 --- /dev/null +++ b/tuts/096-aws-codecommit-gs/REVISION-HISTORY.md @@ -0,0 +1,8 @@ +# Revision History: 096-aws-codecommit-gs + +## Shell (CLI script) + +### 2026-04-14 v1 published +- Type: functional +- Initial version + diff --git a/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh b/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh index f88c5002..4be7dc8d 100644 --- a/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh +++ b/tuts/096-aws-codecommit-gs/aws-codecommit-gs.sh @@ -14,7 +14,7 @@ fi export AWS_DEFAULT_REGION="$REGION" echo "Region: $REGION" -RANDOM_ID=$(openssl rand -hex 4) +RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1) REPO_NAME="tutorial-repo-${RANDOM_ID}" handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; } diff --git a/tuts/098-aws-codebuild-gs/README.md b/tuts/098-aws-codebuild-gs/README.md index b0b1f8d3..683aad77 100644 --- a/tuts/098-aws-codebuild-gs/README.md +++ b/tuts/098-aws-codebuild-gs/README.md @@ -51,15 +51,3 @@ CodeBuild free tier includes 100 build minutes per month on general1.small. No c - [Build specification reference](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) - [Build environment reference](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html) - [CodeBuild pricing](https://aws.amazon.com/codebuild/pricing/) - ---- - -## Appendix: Generation details - -| Field | Value | -|-------|-------| -| Generation date | 2026-04-14 | -| Source script | New, 138 lines | -| Script test result | EXIT 0, 37s, 6 steps, no issues | -| Issues encountered | None | -| Iterations | v1 | diff --git a/tuts/098-aws-codebuild-gs/REVISION-HISTORY.md b/tuts/098-aws-codebuild-gs/REVISION-HISTORY.md new file mode 100644 index 00000000..2099860b --- /dev/null +++ b/tuts/098-aws-codebuild-gs/REVISION-HISTORY.md @@ -0,0 +1,8 @@ +# Revision History: 098-aws-codebuild-gs + +## Shell (CLI script) + +### 2026-04-14 v1 published +- Type: functional +- Initial version + diff --git a/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh b/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh index 87094324..ef90c08c 100644 --- a/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh +++ b/tuts/098-aws-codebuild-gs/aws-codebuild-gs.sh @@ -15,7 +15,7 @@ export AWS_DEFAULT_REGION="$REGION" ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text) echo "Region: $REGION" -RANDOM_ID=$(openssl rand -hex 4) +RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1) BUCKET_NAME="codebuild-tut-${RANDOM_ID}-${ACCOUNT_ID}" PROJECT_NAME="tut-build-${RANDOM_ID}" ROLE_NAME="codebuild-tut-role-${RANDOM_ID}" diff --git a/tuts/125-aws-codeartifact-gs/REVISION-HISTORY.md b/tuts/125-aws-codeartifact-gs/REVISION-HISTORY.md new file mode 100644 index 00000000..f43cbc87 --- /dev/null +++ b/tuts/125-aws-codeartifact-gs/REVISION-HISTORY.md @@ -0,0 +1,8 @@ +# Revision History: 125-aws-codeartifact-gs + +## Shell (CLI script) + +### 2026-04-14 v1 published +- Type: functional +- Initial version + diff --git a/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh b/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh index d2b54026..5278d0cb 100644 --- a/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh +++ b/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.sh @@ -1,12 +1,12 @@ #!/bin/bash WORK_DIR=$(mktemp -d) exec > >(tee -a "$WORK_DIR/codeartifact-$(date +%Y%m%d-%H%M%S).log") 2>&1 -REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)} +REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))} [ -z "$REGION" ] && echo "ERROR: No region" && exit 1 export AWS_DEFAULT_REGION="$REGION" ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text) echo "Region: $REGION" -RANDOM_ID=$(openssl rand -hex 4) +RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1) DOMAIN="tut-domain-${RANDOM_ID}" REPO="tut-repo-${RANDOM_ID}" handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; } diff --git a/tuts/135-aws-codedeploy-gs/REVISION-HISTORY.md b/tuts/135-aws-codedeploy-gs/REVISION-HISTORY.md new file mode 100644 index 00000000..581bdf66 --- /dev/null +++ b/tuts/135-aws-codedeploy-gs/REVISION-HISTORY.md @@ -0,0 +1,8 @@ +# Revision History: 135-aws-codedeploy-gs + +## Shell (CLI script) + +### 2026-04-14 v1 published +- Type: functional +- Initial version + diff --git a/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh b/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh index 410c900d..80f6f776 100644 --- a/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh +++ b/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.sh @@ -1,7 +1,7 @@ #!/bin/bash WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/codedeploy.log") 2>&1 -REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION" -RANDOM_ID=$(openssl rand -hex 4); APP_NAME="tut-app-${RANDOM_ID}" +REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION" +RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); APP_NAME="tut-app-${RANDOM_ID}" handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR cleanup() { echo ""; echo "Cleaning up..."; aws deploy delete-application --application-name "$APP_NAME" 2>/dev/null && echo " Deleted app"; rm -rf "$WORK_DIR"; echo "Done."; } echo "Step 1: Creating application: $APP_NAME" diff --git a/tuts/136-aws-codepipeline-gs/REVISION-HISTORY.md b/tuts/136-aws-codepipeline-gs/REVISION-HISTORY.md new file mode 100644 index 00000000..aa362236 --- /dev/null +++ b/tuts/136-aws-codepipeline-gs/REVISION-HISTORY.md @@ -0,0 +1,8 @@ +# Revision History: 136-aws-codepipeline-gs + +## Shell (CLI script) + +### 2026-04-14 v1 published +- Type: functional +- Initial version + diff --git a/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh b/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh index 3526c2fe..bc06b000 100644 --- a/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh +++ b/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.sh @@ -1,7 +1,7 @@ #!/bin/bash WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/codepipeline.log") 2>&1 -REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text); echo "Region: $REGION" -RANDOM_ID=$(openssl rand -hex 4); PIPE_NAME="tut-pipe-${RANDOM_ID}"; BUCKET="codepipeline-tut-${RANDOM_ID}-${ACCOUNT}"; ROLE_NAME="codepipeline-tut-role-${RANDOM_ID}" +REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text); echo "Region: $REGION" +RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); PIPE_NAME="tut-pipe-${RANDOM_ID}"; BUCKET="codepipeline-tut-${RANDOM_ID}-${ACCOUNT}"; ROLE_NAME="codepipeline-tut-role-${RANDOM_ID}" handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR cleanup() { echo ""; echo "Cleaning up..."; aws codepipeline delete-pipeline --name "$PIPE_NAME" 2>/dev/null && echo " Deleted pipeline"; aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name pipe-policy 2>/dev/null; aws iam delete-role --role-name "$ROLE_NAME" 2>/dev/null && echo " Deleted role"; if aws s3 ls "s3://$BUCKET" > /dev/null 2>&1; then aws s3 rm "s3://$BUCKET" --recursive --quiet; aws s3 rb "s3://$BUCKET" && echo " Deleted bucket"; fi; rm -rf "$WORK_DIR"; echo "Done."; } echo "Step 1: Creating S3 bucket for artifacts" From 20cd7a61594f842eab21e85b9f89aed04bf71fd9 Mon Sep 17 00:00:00 2001 From: Michael Wunderlich Date: Tue, 21 Apr 2026 05:38:00 +0000 Subject: [PATCH 3/3] Add README.md and tutorial walkthrough for script-only tutorials --- tuts/125-aws-codeartifact-gs/README.md | 39 +++++++++++++++++ .../aws-codeartifact-gs.md | 31 +++++++++++++ tuts/135-aws-codedeploy-gs/README.md | 36 ++++++++++++++++ .../aws-codedeploy-gs.md | 23 ++++++++++ tuts/136-aws-codepipeline-gs/README.md | 43 +++++++++++++++++++ .../aws-codepipeline-gs.md | 31 +++++++++++++ 6 files changed, 203 insertions(+) create mode 100644 tuts/125-aws-codeartifact-gs/README.md create mode 100644 tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.md create mode 100644 tuts/135-aws-codedeploy-gs/README.md create mode 100644 tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.md create mode 100644 tuts/136-aws-codepipeline-gs/README.md create mode 100644 tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.md diff --git a/tuts/125-aws-codeartifact-gs/README.md b/tuts/125-aws-codeartifact-gs/README.md new file mode 100644 index 00000000..e4f294d4 --- /dev/null +++ b/tuts/125-aws-codeartifact-gs/README.md @@ -0,0 +1,39 @@ +# Aws Codeartifact Gs + +An AWS CLI tutorial that demonstrates Codeartifact operations. + +## Running + +```bash +bash aws-codeartifact-gs.sh +``` + +To auto-run with cleanup: + +```bash +echo 'y' | bash aws-codeartifact-gs.sh +``` + +## What it does + +1. Creating domain: $DOMAIN +2. Creating repository: $REPO +3. Getting authorization token +4. Getting repository endpoint +5. Listing repositories + +## Resources created + +- Domain +- Repository + +The script prompts you to clean up resources when it finishes. + +## Cost + +Free tier eligible for most operations. Clean up resources after use to avoid charges. + +## Related docs + +- [AWS CLI codeartifact reference](https://docs.aws.amazon.com/cli/latest/reference/codeartifact/index.html) + diff --git a/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.md b/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.md new file mode 100644 index 00000000..8f67df68 --- /dev/null +++ b/tuts/125-aws-codeartifact-gs/aws-codeartifact-gs.md @@ -0,0 +1,31 @@ +# Aws Codeartifact Gs + +## Prerequisites + +1. AWS CLI installed and configured (`aws configure`) +2. Appropriate IAM permissions for the AWS services used + +## Step 1: Creating domain: $DOMAIN + +The script handles this step automatically. See `aws-codeartifact-gs.sh` for the exact CLI commands. + +## Step 2: Creating repository: $REPO + +The script handles this step automatically. See `aws-codeartifact-gs.sh` for the exact CLI commands. + +## Step 3: Getting authorization token + +The script handles this step automatically. See `aws-codeartifact-gs.sh` for the exact CLI commands. + +## Step 4: Getting repository endpoint + +The script handles this step automatically. See `aws-codeartifact-gs.sh` for the exact CLI commands. + +## Step 5: Listing repositories + +The script handles this step automatically. See `aws-codeartifact-gs.sh` for the exact CLI commands. + +## Cleanup + +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. + diff --git a/tuts/135-aws-codedeploy-gs/README.md b/tuts/135-aws-codedeploy-gs/README.md new file mode 100644 index 00000000..e524f201 --- /dev/null +++ b/tuts/135-aws-codedeploy-gs/README.md @@ -0,0 +1,36 @@ +# Aws Codedeploy Gs + +An AWS CLI tutorial that demonstrates Deploy operations. + +## Running + +```bash +bash aws-codedeploy-gs.sh +``` + +To auto-run with cleanup: + +```bash +echo 'y' | bash aws-codedeploy-gs.sh +``` + +## What it does + +1. Creating application: $APP_NAME +2. Listing applications +3. Getting application details + +## Resources created + +- Application + +The script prompts you to clean up resources when it finishes. + +## Cost + +Free tier eligible for most operations. Clean up resources after use to avoid charges. + +## Related docs + +- [AWS CLI deploy reference](https://docs.aws.amazon.com/cli/latest/reference/deploy/index.html) + diff --git a/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.md b/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.md new file mode 100644 index 00000000..a1eb2ebb --- /dev/null +++ b/tuts/135-aws-codedeploy-gs/aws-codedeploy-gs.md @@ -0,0 +1,23 @@ +# Aws Codedeploy Gs + +## Prerequisites + +1. AWS CLI installed and configured (`aws configure`) +2. Appropriate IAM permissions for the AWS services used + +## Step 1: Creating application: $APP_NAME + +The script handles this step automatically. See `aws-codedeploy-gs.sh` for the exact CLI commands. + +## Step 2: Listing applications + +The script handles this step automatically. See `aws-codedeploy-gs.sh` for the exact CLI commands. + +## Step 3: Getting application details + +The script handles this step automatically. See `aws-codedeploy-gs.sh` for the exact CLI commands. + +## Cleanup + +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. + diff --git a/tuts/136-aws-codepipeline-gs/README.md b/tuts/136-aws-codepipeline-gs/README.md new file mode 100644 index 00000000..7b5f1446 --- /dev/null +++ b/tuts/136-aws-codepipeline-gs/README.md @@ -0,0 +1,43 @@ +# Aws Codepipeline Gs + +An AWS CLI tutorial that demonstrates Codepipeline operations. + +## Running + +```bash +bash aws-codepipeline-gs.sh +``` + +To auto-run with cleanup: + +```bash +echo 'y' | bash aws-codepipeline-gs.sh +``` + +## What it does + +1. Creating S3 bucket for artifacts +2. Creating IAM role +3. Creating pipeline: $PIPE_NAME +4. Getting pipeline state +5. Listing pipelines + +## Resources created + +- Bucket +- Pipeline +- Role +- Role Policy + +The script prompts you to clean up resources when it finishes. + +## Cost + +Free tier eligible for most operations. Clean up resources after use to avoid charges. + +## Related docs + +- [AWS CLI codepipeline reference](https://docs.aws.amazon.com/cli/latest/reference/codepipeline/index.html) +- [AWS CLI iam reference](https://docs.aws.amazon.com/cli/latest/reference/iam/index.html) +- [AWS CLI s3 reference](https://docs.aws.amazon.com/cli/latest/reference/s3/index.html) + diff --git a/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.md b/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.md new file mode 100644 index 00000000..ee28bf3a --- /dev/null +++ b/tuts/136-aws-codepipeline-gs/aws-codepipeline-gs.md @@ -0,0 +1,31 @@ +# Aws Codepipeline Gs + +## Prerequisites + +1. AWS CLI installed and configured (`aws configure`) +2. Appropriate IAM permissions for the AWS services used + +## Step 1: Creating S3 bucket for artifacts + +The script handles this step automatically. See `aws-codepipeline-gs.sh` for the exact CLI commands. + +## Step 2: Creating IAM role + +The script handles this step automatically. See `aws-codepipeline-gs.sh` for the exact CLI commands. + +## Step 3: Creating pipeline: $PIPE_NAME + +The script handles this step automatically. See `aws-codepipeline-gs.sh` for the exact CLI commands. + +## Step 4: Getting pipeline state + +The script handles this step automatically. See `aws-codepipeline-gs.sh` for the exact CLI commands. + +## Step 5: Listing pipelines + +The script handles this step automatically. See `aws-codepipeline-gs.sh` for the exact CLI commands. + +## Cleanup + +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. +