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
25 changes: 22 additions & 3 deletions Cloud9Setup/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Setup Cloud9
sam build -t prereq-sam-template.yaml --use-container
sam deploy
# Setup Development Environment

## Option 1: VSCode Server (Recommended)
The Cloud9 service is being deprecated. We recommend using VSCode Server instead.

```bash
# Option 1: Using command line parameters
sam build -t ../event-engine-assets/vscode-module-sam-template.yaml --use-container
sam deploy --stack-name serverless-saas-vscode-env --capabilities CAPABILITY_NAMED_IAM

# Option 2: Using the provided samconfig.toml file
sam build -t ../event-engine-assets/vscode-module-sam-template.yaml --use-container
sam deploy --config-file ../event-engine-assets/samconfig.toml
```

After deployment completes, you can access the VSCode Server environment using the URL and password provided in the CloudFormation outputs.

## Option 2: Cloud9 (Legacy)
If you still need to use Cloud9 (not recommended for new deployments):

```bash
sam build -t prereq-sam-template.yaml --use-container
sam deploy
```
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ This workshop is inspired by the [SaaS Factory Serverless SaaS reference solutio
# Starting the workshop
Follow this link for detailed instructions to run this workshop in your AWS Account: https://catalog.us-east-1.prod.workshops.aws/v2/workshops/b0c6ad36-0a4b-45d8-856b-8a64f0ac76bb/en-US

## Development Environment Options

This workshop provides two options for setting up your development environment:

1. **VSCode Server (Recommended)**: A modern, feature-rich development environment that replaces Cloud9 (which is being deprecated). See the [VSCodeSetup](./VSCodeSetup/README.md) directory for instructions.

2. **Cloud9 (Legacy)**: The original Cloud9-based development environment. This option is maintained for backward compatibility but is not recommended for new deployments. See the [Cloud9Setup](./Cloud9Setup/README.md) directory for instructions.

For more details on the VSCode Server setup, see the [event-engine-assets](./event-engine-assets/README.md) directory.

# License
The documentation is made available under the Creative Commons Attribution-ShareAlike 4.0 International License. See the LICENSE file.

Expand Down
4 changes: 4 additions & 0 deletions VSCodeSetup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.aws-sam/
.pytest_cache/
.DS_Store
.vscode/
72 changes: 72 additions & 0 deletions VSCodeSetup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Setup VSCode Server Development Environment

This directory contains scripts and instructions for setting up a VSCode Server development environment for the AWS Serverless SaaS Workshop.

## Deployment Options

### Option 1: Using command line parameters
```bash
sam build -t ../event-engine-assets/vscode-module-sam-template.yaml --use-container
sam deploy --stack-name serverless-saas-vscode-env --capabilities CAPABILITY_NAMED_IAM
```

### Option 2: Using the provided samconfig.toml file
```bash
# Using the samconfig.toml in the event-engine-assets directory
sam build -t ../event-engine-assets/vscode-module-sam-template.yaml --use-container
sam deploy --config-file ../event-engine-assets/samconfig.toml

# Or using the samconfig.toml in this directory
sam build -t ../event-engine-assets/vscode-module-sam-template.yaml --use-container
sam deploy --config-file samconfig.toml
```

After deployment completes, you can access the VSCode Server environment using the URL and password provided in the CloudFormation outputs. The URL will open VSCode Server at the /Workshop directory, where the aws-serverless-saas-workshop repository has been cloned.

## Scripts

### pre-requisites.sh
This script installs all the necessary tools and dependencies for the workshop, including:
- Python 3.8+
- AWS CLI
- SAM CLI
- Node.js
- CDK CLI
- git-remote-codecommit
- VSCode Server specific requirements (nginx, code-server)

### pre-requisites-versions-check.sh
This script checks if all the required tools and dependencies are installed with the correct versions. It also verifies that the VSCode Server instance is properly configured.

### increase-disk-size.sh
This script increases the EBS volume size of the VSCode Server instance to 50 GiB.

## Usage

1. Deploy the VSCode Server environment using one of the deployment options above.
2. Connect to the VSCode Server environment using the URL and password provided in the CloudFormation outputs.
3. Run the pre-requisites-versions-check.sh script to verify that all required tools are installed:
```bash
cd VSCodeSetup
chmod +x pre-requisites-versions-check.sh
./pre-requisites-versions-check.sh
```
4. If any tools are missing or have incorrect versions, run the pre-requisites.sh script:
```bash
chmod +x pre-requisites.sh
./pre-requisites.sh
```
5. If you need to increase the disk size, run the increase-disk-size.sh script:
```bash
chmod +x increase-disk-size.sh
./increase-disk-size.sh
```

## Differences from Cloud9

VSCode Server provides several advantages over Cloud9:
- Modern, feature-rich IDE experience
- Better performance and stability
- Continued support (Cloud9 is being deprecated)
- More customization options
- Better extension support
61 changes: 61 additions & 0 deletions VSCodeSetup/increase-disk-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

# Specify the desired volume size in GiB as a command line argument. If not specified, default to 50 GiB.
SIZE=50

# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/')

# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \
--instance-id $INSTANCEID \
--query "Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId" \
--output text \
--region $REGION)

# Resize the EBS volume.
aws ec2 modify-volume --volume-id $VOLUMEID --size $SIZE

# Wait for the resize to finish.
while [ \
"$(aws ec2 describe-volumes-modifications \
--volume-id $VOLUMEID \
--filters Name=modification-state,Values="optimizing","completed" \
--query "length(VolumesModifications)"\
--output text)" != "1" ]; do
sleep 1
done

#Check if we're on an NVMe filesystem
if [[ -e "/dev/xvda" && $(readlink -f /dev/xvda) = "/dev/xvda" ]]
then
# Rewrite the partition table so that the partition takes up all the space that it can.
sudo growpart /dev/xvda 1

# Expand the size of the file system.
# Check if we're on AL2
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/xvda1
fi

else
# Rewrite the partition table so that the partition takes up all the space that it can.
sudo growpart /dev/nvme0n1 1

# Expand the size of the file system.
# Check if we're on AL2
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/nvme0n1p1
fi
fi
151 changes: 151 additions & 0 deletions VSCodeSetup/pre-requisites-versions-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/bin/bash
SUMMARY="Make sure all the pre-requisites checks PASS"$'\n'
check_version() {
retval=0
MIN_VERSION=$1
CURRENT_VERSION=$2
IFS='.' read -r -a minarr <<< "$MIN_VERSION"
IFS='.' read -r -a currarr <<< "$CURRENT_VERSION"

for ((i=0; i<${#minarr[@]}; i++));
do
#echo "${currarr[$i]}, ${minarr[$i]}"
if [[ ${currarr[$i]} -gt ${minarr[$i]} ]]; then
break
elif [[ ${currarr[$i]} -lt ${minarr[$i]} ]]; then
retval=1
break
else
continue
fi
done

return $retval
}

echo "Checking python version"
python3 --version
PYTHON_VERSION=$(python3 --version 2>&1 | cut -d'n' -f 2 | xargs)
PYTHON_MIN_VERSION=3.8.0
check_version $PYTHON_MIN_VERSION $PYTHON_VERSION
if [[ $? -eq 1 ]]; then
echo "ACTION REQUIRED: Need to have python version greater than or equal to $PYTHON_MIN_VERSION"
SUMMARY+="* ACTION REQUIRED: Need to have python version greater than or equal to $PYTHON_MIN_VERSION"$'\n'
else
SUMMARY+="* PASS : Python version $PYTHON_VERSION installed. The minimum required version $PYTHON_MIN_VERSION"$'\n'
fi
echo ""

echo "Checking aws cli version"
aws --version
if [[ $? -ne 0 ]]; then
echo "ACTION REQUIRED: aws cli is missing, please install !!"
SUMMARY+="* ACTION REQUIRED: aws cli is missing, please install !!"$'\n'
else
AWS_VERSION=$(aws --version | cut -d'P' -f 1 | xargs)
SUMMARY+="* PASS : $AWS_VERSION version installed"$'\n'
jq --version
if [[ $? -ne 0 ]]; then
echo yes | sudo yum install jq
fi
# Check for VSCode Server instance instead of Cloud9
VSCODE_INSTANCE=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=ServerlessSaaS-VSCode" | jq -r '.Reservations[0].Instances[0].InstanceId')
if [ -z "$VSCODE_INSTANCE" ]; then
echo "ACTION REQUIRED: Looks like VSCode Server instance is missing. Please create one using the vscode-module-sam-template.yaml template!!"
SUMMARY+="* ACTION REQUIRED: Looks like VSCode Server instance is missing. Please create one using the vscode-module-sam-template.yaml template!!"$'\n'
else
SUMMARY+="* PASS : VSCode Server instance found"$'\n'
VSCODE_INSTANCE_VOLUME_ID=$(aws ec2 describe-instances --instance-ids $VSCODE_INSTANCE | jq -r '.Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId')
VOLUME_SIZE=$(aws ec2 describe-volumes --volume-ids $VSCODE_INSTANCE_VOLUME_ID | jq -r '.Volumes[0].Size')
if [[ $VOLUME_SIZE -lt 50 ]]; then
echo "ACTION REQUIRED: The volume size of VSCode Server is less than 50GiB. Please update volume size to at least 50GiB"
SUMMARY+="* ACTION REQUIRED: The volume size of VSCode Server is less than 50GiB. Please update volume size to at least 50GiB"$'\n'
else
SUMMARY+="* PASS : Has minimum required 50GiB volume size"$'\n'
fi

# Check for CloudFront distribution
CLOUDFRONT_DIST=$(aws cloudfront list-distributions | jq -r '.DistributionList.Items[] | select(.Origins.Items[0].DomainName | contains("'$VSCODE_INSTANCE'")) | .Id')
if [ -z "$CLOUDFRONT_DIST" ]; then
echo "ACTION REQUIRED: CloudFront distribution for VSCode Server not found. Please check your deployment."
SUMMARY+="* ACTION REQUIRED: CloudFront distribution for VSCode Server not found. Please check your deployment."$'\n'
else
SUMMARY+="* PASS : CloudFront distribution for VSCode Server found"$'\n'
fi
fi
fi
echo ""

echo "Checking sam cli version"
sam --version
SAM_VERSION=$(sam --version | cut -d'n' -f 2 | xargs)
SAM_MIN_VERSION=1.53.0
check_version $SAM_MIN_VERSION $SAM_VERSION
if [[ $? -eq 1 ]]; then
echo "ACTION REQUIRED: Need to have SAM version greater than or equal to $SAM_MIN_VERSION"
SUMMARY+="* ACTION REQUIRED: Need to have SAM version greater than or equal to $SAM_MIN_VERSION"$'\n'
else
SUMMARY+="* PASS : Sam cli version $SAM_VERSION installed. The minimum required version $SAM_MIN_VERSION"$'\n'
fi
echo ""

echo "Checking git-remote-codecommit version"
python3 -m pip show git-remote-codecommit
if [[ $? -ne 0 ]]; then
echo "ACTION REQUIRED: git-remote-codecommit is missing, please install"
SUMMARY+="* ACTION REQUIRED: git-remote-codecommit is missing, please install !!"$'\n'
else
SUMMARY+="* PASS : Has git-remote-codecommit installed"$'\n'
fi
echo ""

echo "Checking node version"
node --version
NODE_VERSION=$(node --version | cut -d'v' -f 2)
NODE_MIN_VERSION=14.0.0
check_version $NODE_MIN_VERSION $NODE_VERSION
if [[ $? -eq 1 ]]; then
echo "ACTION REQUIRED: Need to have Node version greater than or equal to $NODE_MIN_VERSION"
SUMMARY+="* ACTION REQUIRED: Need to have Node version greater than or equal to $NODE_MIN_VERSION"$'\n'
else
SUMMARY+="* PASS : Node version $NODE_VERSION installed. The minimum required version $NODE_MIN_VERSION"$'\n'
fi
echo ""

echo "Checking cdk version"
cdk --version
CDK_VERSION=$(cdk --version | cut -d'(' -f 1| xargs)
CDK_MIN_VERSION=2.40.0
check_version $CDK_MIN_VERSION $CDK_VERSION
if [[ $? -eq 1 ]]; then
echo "ACTION REQUIRED: Need to have CDK version greater than or equal to $CDK_MIN_VERSION"
SUMMARY+="* ACTION REQUIRED: Need to have CDK version greater than or equal to $CDK_MIN_VERSION"$'\n'
else
SUMMARY+="* PASS : CDK version $CDK_VERSION installed. The minimum required version $CDK_MIN_VERSION"$'\n'
fi
echo ""

# Check for VSCode Server specific requirements
echo "Checking nginx installation"
nginx -v
if [[ $? -ne 0 ]]; then
echo "ACTION REQUIRED: nginx is missing, please install"
SUMMARY+="* ACTION REQUIRED: nginx is missing, please install !!"$'\n'
else
SUMMARY+="* PASS : nginx is installed"$'\n'
fi
echo ""

echo "Checking code-server installation"
code-server --version
if [[ $? -ne 0 ]]; then
echo "ACTION REQUIRED: code-server is missing, please install"
SUMMARY+="* ACTION REQUIRED: code-server is missing, please install !!"$'\n'
else
SUMMARY+="* PASS : code-server is installed"$'\n'
fi
echo ""

echo "***************SUMMARY****************"
echo "$SUMMARY"
echo "***************END OF SUMMARY*********"
Loading