Skip to content
Open
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
34 changes: 34 additions & 0 deletions tuts/127-appconfig-gs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AWS AppConfig — Getting Started Tutorial

Demonstrates the core AWS AppConfig workflow: creating resources, verifying them, and cleaning up.

## Prerequisites

- AWS CLI v2 installed and configured
- Python 3.9+ with boto3
- IAM permissions for appconfig:Create*, appconfig:Delete*, appconfig:Get*, appconfig:List*
- (Optional) TUTORIAL_ROLE_ARN environment variable if the service requires a role

## Run

**Python:**
```bash
python3 appconfig-gs.py
```

**CLI:**
```bash
bash appconfig-gs.sh
```

Both scripts create resources, verify them, and clean up automatically.

## Files

| File | Description |
|------|-------------|
| `appconfig-gs.py` | Python (boto3) tutorial script |
| `appconfig-gs.sh` | AWS CLI tutorial script |
| `appconfig-tutorial.md` | Step-by-step tutorial document |

Generated by automated pipeline and validated by agent container.
85 changes: 85 additions & 0 deletions tuts/127-appconfig-gs/appconfig-gs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import boto3
import json
import time
import os
import random
import string

client = boto3.client('appconfig', region_name='us-east-1')
ROLE_ARN = os.environ.get('TUTORIAL_ROLE_ARN')
suffix = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
tags = {'project': 'doc-smith', 'tutorial': 'appconfig-gs'}

print("Creating an application...")
application_name = f"appconfig-app-{suffix}"
application_response = client.create_application(
Name=application_name,
Description="Test Application",
Tags=tags
)
application_id = application_response['Id']
print(f"Created Application: {application_name}")

print("Creating an environment...")
environment_name = f"appconfig-env-{suffix}"
environment_response = client.create_environment(
ApplicationId=application_id,
Name=environment_name,
Description="Test Environment",
Tags=tags
)
environment_id = environment_response['Id']
print(f"Created Environment: {environment_name}")

print("Creating a configuration profile...")
config_profile_name = f"appconfig-config-{suffix}"
location_uri = "ssm-parameter://appconfig-test-parameter"

if ROLE_ARN:
config_profile_response = client.create_configuration_profile(
ApplicationId=application_id,
Name=config_profile_name,
Description="Test Configuration Profile",
LocationUri=location_uri,
RetrievalRoleArn=ROLE_ARN,
Tags=tags
)
config_profile_id = config_profile_response['Id']
print(f"Created Configuration Profile: {config_profile_name}")
else:
print(f"Skipped creating Configuration Profile: {config_profile_name} due to missing role ARN")

print("Verifying resources...")
time.sleep(10) # Wait for resources to be available

get_application_response = client.get_application(ApplicationId=application_id)
print(f"Verified Application: {get_application_response['Name']}")

if ROLE_ARN:
get_config_profile_response = client.get_configuration_profile(ApplicationId=application_id, ConfigurationProfileId=config_profile_id)
print(f"Verified Configuration Profile: {get_config_profile_response['Name']}")

get_environment_response = client.get_environment(ApplicationId=application_id, EnvironmentId=environment_id)
print(f"Verified Environment: {get_environment_response['Name']}")

print("Cleaning up...")

client.delete_environment(
ApplicationId=application_id,
EnvironmentId=environment_id
)
print(f"Deleted Environment: {environment_name}")

if ROLE_ARN:
client.delete_configuration_profile(
ApplicationId=application_id,
ConfigurationProfileId=config_profile_id
)
print(f"Deleted Configuration Profile: {config_profile_name}")

client.delete_application(
ApplicationId=application_id
)
print(f"Deleted Application: {application_name}")

print("PASS")
39 changes: 39 additions & 0 deletions tuts/127-appconfig-gs/appconfig-gs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -e

cleanup_resources() {
for resource in "${CREATED_RESOURCES[@]}"; do
echo "Cleaning up resource: $resource"
case $resource in
application/*) aws appconfig delete-application --application-id "${resource#application/}" || true ;;
configuration-profile/*) aws appconfig delete-configuration-profile --application-id "${resource#configuration-profile/}" || true ;;
deployment-strategy/*) aws appconfig delete-deployment-strategy --deployment-strategy-id "${resource#deployment-strategy/}" || true ;;
environment/*) aws appconfig delete-environment --application-id "${resource#environment/}" || true ;;
extension/*) aws appconfig delete-extension --extension-id "${resource#extension/}" || true ;;
esac
done
}

trap cleanup_resources EXIT

SUFFIX=$(head -c 20 /dev/urandom | base64 | tr -dc a-z0-9 | head -c 8 || true)
TEMP_DIR=$(mktemp -d)
CREATED_RESOURCES=()

echo "Creating an application..."
APPLICATION_ID=$(aws appconfig create-application --name "app-$SUFFIX" --tags '{"Project":"Tutorial","Environment":"Dev"}' --query 'Id' --output text)
CREATED_RESOURCES+=("application/$APPLICATION_ID")

echo "Creating a configuration profile..."
CONFIG_PROFILE_ID=$(aws appconfig create-configuration-profile --application-id "$APPLICATION_ID" --name "config-$SUFFIX" --location-uri "ssm-parameter://tutorial-param" --retrieval-role-arn "$ROLE_ARN" --tags '{"Project":"Tutorial","Environment":"Dev"}' --query 'Id' --output text)
CREATED_RESOURCES+=("configuration-profile/$CONFIG_PROFILE_ID")

echo "Creating a deployment strategy..."
DEPLOYMENT_STRATEGY_ID=$(aws appconfig create-deployment-strategy --name "strategy-$SUFFIX" --deployment-duration-in-minutes 15 --final-bake-time-in-minutes 30 --growth-factor 25 --growth-type LINEAR --tags '{"Project":"Tutorial","Environment":"Dev"}' --query 'Id' --output text)
CREATED_RESOURCES+=("deployment-strategy/$DEPLOYMENT_STRATEGY_ID")

echo "Creating an environment..."
ENVIRONMENT_ID=$(aws appconfig create-environment --application-id "$APPLICATION_ID" --name "env-$SUFFIX" --tags '{"Project":"Tutorial","Environment":"Dev"}' --query 'Id' --output text)
CREATED_RESOURCES+=("environment/$ENVIRONMENT_ID")

echo "PASS"
168 changes: 168 additions & 0 deletions tuts/127-appconfig-gs/appconfig-tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Getting started with AWS AppConfig

## Prerequisites

Before you begin, ensure you have the following:

- AWS CLI installed and configured
- Appropriate IAM permissions to create and manage AWS AppConfig resources
- An IAM role with permissions to retrieve configuration data (if using SSM Parameter Store)

If you need to create IAM roles or policies, consider using AWS CloudFormation to manage your stack.

## Step 1: Create an application

**Create an application**

This step involves creating an AWS AppConfig application, which is a logical grouping of configuration items.

```python
# Python
import boto3
import time
import os

appconfig_client = boto3.client('appconfig')
suffix = str(int(time.time()))[-6:]
tags = [{'Key':'project','Value':'doc-smith'},{'Key':'tutorial','Value':'appconfig-gs'}]

response = appconfig_client.create_application(
Name=f"appconfig-tutorial-app-{suffix}",
Description="Tutorial Application",
Tags=tags
)
application_id = response['Id']
print(f"Application 'appconfig-tutorial-app-{suffix}' created with ID: {application_id}")
```

```bash
$ aws appconfig create-application --name "app-$SUFFIX" --tags '{"Project":"Tutorial","Environment":"Dev"}'
```

**Expected result**

You should see output similar to:

```
Application 'appconfig-tutorial-app-123456' created with ID: abc123
```

## Step 2: Create a configuration profile

**Create a configuration profile**

A configuration profile defines where your configuration data is stored and how it is retrieved.

```python
# Python
response = appconfig_client.create_configuration_profile(
ApplicationId=application_id,
Name=f"appconfig-tutorial-config-{suffix}",
Description="Tutorial Configuration Profile",
LocationUri="ssm-parameter://tutorial-parameter",
RetrieveRoleArn=ROLE_ARN if ROLE_ARN else boto3.client('sts').get_caller_identity().get('Arn'),
Tags=tags
)
configuration_profile_id = response['Id']
print(f"Configuration Profile 'appconfig-tutorial-config-{suffix}' created with ID: {configuration_profile_id}")
```

```bash
$ aws appconfig create-configuration-profile --application-id "$APPLICATION_ID" --name "config-$SUFFIX" --location-uri "ssm-parameter://tutorial-param" --retrieval-role-arn "$ROLE_ARN"
```

**Expected result**

You should see output similar to:

```
Configuration Profile 'appconfig-tutorial-config-123456' created with ID: def456
```

## Step 3: Create an environment

**Create an environment**

An environment represents a group of applications that you want to deploy configurations to.

```python
# Python
response = appconfig_client.create_environment(
ApplicationId=application_id,
Name=f"appconfig-tutorial-env-{suffix}",
Description="Tutorial Environment",
Tags=tags
)
environment_id = response['Id']
print(f"Environment 'appconfig-tutorial-env-{suffix}' created with ID: {environment_id}")
```

```bash
$ aws appconfig create-environment --application-id "$APPLICATION_ID" --name "env-$SUFFIX"
```

**Expected result**

You should see output similar to:

```
Environment 'appconfig-tutorial-env-123456' created with ID: ghi789
```

## Step 4: Create a deployment strategy

**Create a deployment strategy**

A deployment strategy defines how a configuration is deployed to an environment.

```python
# Python
response = appconfig_client.create_deployment_strategy(
Name=f"appconfig-tutorial-strategy-{suffix}",
Description="Tutorial Deployment Strategy",
DeploymentDurationInMinutes=15,
FinalBakeTimeInMinutes=30,
GrowthType='LINEAR',
GrowthFactor=25,
ReplicateTo='NONE',
Tags=tags
)
deployment_strategy_id = response['Id']
print(f"Deployment Strategy 'appconfig-tutorial-strategy-{suffix}' created with ID: {deployment_strategy_id}")
```

```bash
$ aws appconfig create-deployment-strategy --name "strategy-$SUFFIX" --deployment-duration-in-minutes 15 --final-bake-time-in-minutes 30 --growth-factor 25 --growth-type LINEAR
```

**Expected result**

You should see output similar to:

```
Deployment Strategy 'appconfig-tutorial-strategy-123456' created with ID: jkl012
```

## Clean up

To avoid unnecessary charges, clean up the resources you created. The scripts provided include a cleanup function that deletes all created resources.

```python
# Python
print("Cleaning up resources...")
# Add cleanup code here
```

```bash
$ cleanup_resources
```

**Expected result**

All created resources (application, configuration profile, environment, and deployment strategy) will be deleted.

## Next steps

- Explore [AWS AppConfig features](https://docs.aws.amazon.com/appconfig/latest/userguide/what-is.html) to learn more about advanced configurations.
- Try deploying a configuration to your environment using the [StartDeployment API](https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_StartDeployment.html).
- Monitor your deployments with [AWS CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html).
34 changes: 34 additions & 0 deletions tuts/128-pipes-gs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Amazon EventBridge Pipes — Getting Started Tutorial

Demonstrates the core Amazon EventBridge Pipes workflow: creating resources, verifying them, and cleaning up.

## Prerequisites

- AWS CLI v2 installed and configured
- Python 3.9+ with boto3
- IAM permissions for pipes:Create*, pipes:Delete*, pipes:Get*, pipes:List*
- (Optional) TUTORIAL_ROLE_ARN environment variable if the service requires a role

## Run

**Python:**
```bash
python3 pipes-gs.py
```

**CLI:**
```bash
bash pipes-gs.sh
```

Both scripts create resources, verify them, and clean up automatically.

## Files

| File | Description |
|------|-------------|
| `pipes-gs.py` | Python (boto3) tutorial script |
| `pipes-gs.sh` | AWS CLI tutorial script |
| `pipes-tutorial.md` | Step-by-step tutorial document |

Generated by automated pipeline and validated by agent container.
Loading
Loading