AWS Feed
Hackathons with AWS Cloud9: Collaboration simplified for your next big idea
Many organizations host ideation events to innovate and prototype new ideas faster. These events usually run for a short duration and involve collaboration between members of participating teams. By the end of the event, a successful demonstration of a working prototype is expected and the winner or the next steps are determined. Therefore, it’s important to build a working proof of concept quickly, and to do that teams need to be able to share the code and get peer reviewed in real time.
In this post, you see how AWS Cloud9 can help teams collaborate, pair program, and track each other’s inputs in real time for a successful hackathon experience.
AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you to write, run, and debug code from any machine with just a browser. A shared environment is an AWS Cloud9 development environment that multiple users have been invited to participate in and can edit or view its shared resources.
Pair programming and mob programming are development approaches in which two or more developers collaborate simultaneously to design, code, or test solutions. At the core is the premise that two or more people collaborate on the same code at the same time, which allows for real-time code review and can result in higher quality software.
Hackathons are one of the best ways to collaboratively solve problems, often with code. Cross-functional two-pizza teams compete with limited resources under time constraints to solve a challenging business problem. Several companies have adopted the concept of hackathons to foster a culture of innovation, providing a platform for developers to showcase their creativity and acquire new skills. Teams are either provided a roster of ideas to choose from or come up with their own new idea.
Solution overview
In this post, you create an AWS Cloud9 environment shared with three AWS Identity and Access Management (IAM) users (the hackathon team). You also see how this team can code together to develop a sample serverless application using an AWS Serverless Application Model (AWS SAM) template.
The following diagram illustrates the deployment architecture.
Prerequisites
To complete the steps in this post, you need an AWS account with administrator privileges.
Set up the environment
To start setting up your environment, complete the following steps:
-
- Create an AWS Cloud9 environment in your AWS account.
- Create and attach an instance profile to AWS Cloud9 to call AWS services from an environment.For more information, see Create and store permanent access credentials in an environment.
- On the AWS Cloud9 console, select the environment you just created and choose View details.
- Note the environment ID from the Environment ARN value; we use this ID in a later step.
- In your AWS Cloud9 terminal, create the file usersetup.sh with the following contents:
#USAGE: #STEP 1: Execute following command within Cloud9 terminal to retrieve environment id # aws cloud9 list-environments #STEP 2: Execute following command by providing appropriate parameters: -e ENVIRONMENTID -u USERNAME1,USERNAME2,USERNAME3 # sh usersetup.sh -e 877f86c3bb80418aabc9956580436e9a -u User1,User2 function usage() { echo "USAGE: sh usersetup.sh -e ENVIRONMENTID -u USERNAME1,USERNAME2,USERNAME3" } while getopts ":e:u:" opt; do case $opt in e) if ! aws cloud9 describe-environment-status --environment-id "$OPTARG" 2>&1 >/dev/null; then echo "Please provide valid cloud9 environmentid." usage exit 1 fi environmentId="$OPTARG" ;; u) if [ "$OPTARG" == "" ]; then echo "Please provide comma separated list of usernames." usage exit 1 fi users="$OPTARG" ;; ?) echo "Incorrect arguments." usage exit 1;; esac done if [ "$OPTIND" -lt 5 ]; then echo "Missing required arguments." usage exit 1 fi IFS=',' read -ra userNames <<< "$users" groupName='HackathonUsers' groupPolicy='arn:aws:iam::aws:policy/AdministratorAccess' userArns=() function createUsers() { userList="" if aws iam get-group --group-name $groupName > /dev/null 2>&1; then echo "$groupName group already exists." else if aws iam create-group --group-name $groupName 2>&1 >/dev/null; then echo "Created user group - $groupName." else echo "Error creating user group - $groupName." exit 1 fi fi if aws iam attach-group-policy --policy-arn $groupPolicy --group-name $groupName; then echo "Attached group policy." else echo "Error attaching group policy to - $groupName." exit 1 fi for userName in "${userNames[@]}" ; do randomPwd=`aws secretsmanager get-random-password --require-each-included-type --password-length 20 --no-include-space --output text` userList="$userList"$'n'"Username: $userName, Password: $randomPwd" userArn=`aws iam create-user --user-name $userName --query 'User.Arn' | sed -e 's//.*///g' | tr -d '"'` userArns+=( $userArn ) aws iam wait user-exists --user-name $userName echo "Successfully created user $userName." aws iam create-login-profile --user-name $userName --password $randomPwd --password-reset-required 2>&1 >/dev/null aws iam add-user-to-group --user-name $userName --group-name $groupName done echo "Waiting for users profile setup..." sleep 8 for arn in "${userArns[@]}" ; do aws cloud9 create-environment-membership --environment-id $environmentId --user-arn $arn --permissions read-write 2>&1 >/dev/null done echo "Following users have been created and added to $groupName group." echo "$userList" } createUsers
- Run the following command by replacing the following parameters:
-
- ENVIRONMENTID – The environment ID you saved earlier
- USERNAME1, USERNAME2… – A comma-separated list of users. In this example, we use three users.
sh usersetup.sh -e ENVIRONMENTID -u USERNAME1,USERNAME2,USERNAME3
The script creates the following resources:-
- The number of IAM users that you defined
- The IAM user group HackathonUsers with the users created from previous step assigned with administrator access
- These users are assigned a random password, which must be changed before their first login.
- User passwords can be shared with your team from the AWS Cloud9 Terminal output.
-
- Instruct your team to sign in to the AWS Cloud9 console open the shared environment by choosing Shared with you.
- Run the create-repository command, specifying a unique name, optional description, and optional tags:
aws codecommit create-repository --repository-name hackathon-repo --repository-description "Hackathon repository" --tags Team=hackathon
- Note the cloneUrlHttp value from the output; we use this in a later step.
The environment is now ready for the hackathon team to start coding.
- Instruct your team members to open the shared environment from the AWS Cloud9 dashboard.
- For demo purposes, you can quickly create a sample Python-based Hello World application using the AWS SAM CLI
- Run the following commands to commit the files to the local repo:
cd hackathon-repo git config --global init.defaultBranch main git init git add . git commit -m "Initial commit
- Run the following command to push the local repo to AWS CodeCommit by replacing CLONE_URL_HTTP with the cloneUrlHttp value you noted earlier:
git push <CLONEURLHTTP> —all
For a sample collaboration scenario, watch the video Collaboration with Cloud9 .
Clean up
The cleanup script deletes all the resources it created. Make a local copy of any files you want to save.
- Create a file named cleanup.sh with the following content:
#USAGE: #STEP 1: Execute following command within Cloud9 terminal to retrieve envronment id # aws cloud9 list-environments #STEP 2: Execute following command by providing appropriate parameters: -e ENVIRONMENTID -u USERNAME1,USERNAME2,USERNAME3 # sh cleanup.sh -e 877f86c3bb80418aabc9956580436e9a -u User1,User2 function usage() { echo "USAGE: sh cleanup.sh -e ENVIRONMENTID -u USERNAME1,USERNAME2,USERNAME3" } while getopts ":e:u:" opt; do case $opt in e) if ! aws cloud9 describe-environment-status --environment-id "$OPTARG" 2>&1 >/dev/null; then echo "Please provide valid cloud9 environmentid." usage exit 1 fi environmentId="$OPTARG" ;; u) if [ "$OPTARG" == "" ]; then echo "Please provide comma separated list of usernames." usage exit 1 fi users="$OPTARG" ;; ?) echo "Incorrect arguments." usage exit 1;; esac done if [ "$OPTIND" -lt 5 ]; then echo "Missing required arguments." usage exit 1 fi IFS=',' read -ra userNames <<< "$users" groupName='HackathonUsers' groupPolicy='arn:aws:iam::aws:policy/AdministratorAccess' function cleanUp() { echo "Starting cleanup..." groupExists=false if aws iam get-group --group-name $groupName > /dev/null 2>&1; then groupExists=true else echo "$groupName does not exist." fi for userName in "${userNames[@]}" ; do if ! aws iam get-user --user-name $userName >/dev/null 2>&1; then echo "$userName does not exist." else userArn=$(aws iam get-user --user-name $userName --query 'User.Arn' | tr -d '"') if $groupExists ; then aws iam remove-user-from-group --user-name $userName --group-name $groupName fi aws iam delete-login-profile --user-name $userName if aws iam delete-user --user-name $userName ; then echo "Succesfully deleted $userName" fi aws cloud9 delete-environment-membership --environment-id $environmentId --user-arn $userArn fi done if $groupExists ; then aws iam detach-group-policy --group-name $groupName --policy-arn $groupPolicy if aws iam delete-group --group-name $groupName ; then echo "Succesfully deleted $groupName user group" fi fi echo "Cleanup complete." } cleanUp
- Run the script by passing the same parameters you passed when setting up the script:
sh cleanup.sh -e ENVIRONMENTID -u USERNAME1,USERNAME2,USERNAME3
- Delete the CodeCommit repository by running the following commands in the root directory with the appropriate repository name:
aws codecommit delete-repository —repository-name hackathon-repo rm -rf hackathon-repo
- You can delete the Cloud9 environment when the event is over
Conclusion
In this post, you saw how to use an AWS Cloud9 IDE to collaborate as a team and code together to develop a working prototype. For organizations looking to host hackathon events, these tools can be a powerful way to deliver a rich user experience. For more information about AWS Cloud9 capabilities, see the AWS Cloud9 User Guide. If you plan on using AWS Cloud9 for an ongoing collaboration, refer to the best practices for sharing environments in Working with shared environment in AWS Cloud9.
About the authors
Mahesh Biradar is a Solutions Architect at AWS. He is a DevOps enthusiast and enjoys helping customers implement cost-effective architectures that scale. | |
Guy Savoie is a Senior Solutions Architect at AWS working with SMB customers, primarily in Florida. In his role as a technical advisor, he focuses on unlocking business value through outcome based innovation. | |
Ramesh Chidirala is a Solutions Architect focused on SMB customers in the Central region. He is passionate about helping customers solve challenging technical problems with AWS and help them achieve their desired business outcomes. |