crispy-tk / aws-cloud9-multi-env

AWS Cloud9 environment for development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform and AWS logo

Cloud9 Multi-Environment Provisioning with Terraform

Terraform repo-size

Overview

This project provides a Terraform configuration to provision multiple AWS Cloud9 environments effortlessly. AWS Cloud9 is a cloud-based integrated development environment (IDE) that provides a convenient way to write, run, and debug code in various programming languages. With this Terraform setup, you can easily create and manage multiple Cloud9 environments for your development, testing, or collaborative needs.

Cloud9 UI

Before starting

Be careful how you store your tfstate file as there will be passwords stored. It will not be displayed in the console as it is set as sensitive but still it will be there.

Prerequisites

Before using this project, ensure you have the following prerequisites:

  • An AWS account with the necessary permissions.
  • AWS CLI configured on your local machine with access and secret keys.
  • Terraform installed on your local machine. You can download it from here.
  • Basic familiarity with Terraform and AWS Cloud9.

Getting Started

  1. Clone this repository to your local machine.
git clone https://github.com/crispy-tk/aws-cloud9-multi-env.git
  1. Change into the project directory.
cd aws-cloud9-multi-env
  1. Create a terraform.tfvars file to customize your project. You can adjust parameters such as the instance_type, members_list, and more.

  2. Initialize the Terraform configuration.

terraform init
  1. Review the Terraform execution plan to ensure everything is as expected.
terraform plan
  1. Apply the configuration to create your Cloud9 environments.
terraform apply
  1. Confirm the execution by typing "yes" when prompted.

  2. Terraform will create the Cloud9 environments according to your specifications.

Cloud9 Configuration

To customize your Cloud9 environments, update the terraform.tfvars file with your desired configurations, including but not limited to:

  • region: The region where the Cloud9 will be provisioned.
  • instance_type: The EC2 instance type to use.
  • project: The name of your Cloud9 environment. It will be composed of the project parameter and a name from the new_members and existing_members parameter.
  • new_members: A list of usernames to associate with the Cloud9 environment. The list of names will be used to create new IAM Users and assign to a Cloud IDE.
  • existing_members: A list of exinting users to associate with the Cloud9 environment. The list of names will be used to assign to a Cloud IDE.

Example of Cloud9 environment naming.

myproject-username-{randomID}

You can refer to the AWS Cloud9 documentation for more configuration options.

Examples

Example of terraform.tfvars file.

project = "project-name"
profile = "yourawsprofile"
members_list = ["member01", "member02"]

Cloud9 Documentation

How to Use

  1. Run the following command in the Terminal to retrieve the users passwords.
$ terraform output password
  1. Access the AWS Console using the brand new users and passwords.

  2. Open the Cloud9 URL.

Clean Up

When you no longer need a Cloud9 environment, you can destroy it with Terraform. Run the following command to destroy all the resources:

terraform destroy

Directory Structure

.
├── docs
├── generate-readme.sh
├── images
│   ├── cloud9ui.png
│   └── tf_aws.png
├── LICENSE
├── main.tf
├── provider.tf
├── README.md
└── variables.tf

3 directories, 13 files

Providers

Name Version
aws 5.22.0
random 3.5.1

Inputs

Name Description Type Default Required
existing_members Add existing users to membership. The number of members will determine the number of instances. list(string) n/a yes
new_members Add new users to membership. The number of members will determine the number of instances. list(string) n/a yes
instance_type Define instance type. string "t2.micro" no
members_permissions Permissions are: read-only OR read-write. string "read-write" no
profile Set your AWS CLI profile. string "default" no
project Set your cloud9 project name. string "example" no
region Define the provisioned region. string "us-east-1" no

Outputs

Name Description
cloud9_url Return URL to access the environment
password Return user(s) profile(s) password(s) for console access.

Resources

Name Type
aws_cloud9_environment_ec2.cloud9_instance resource
aws_cloud9_environment_membership.existing_user_membership resource
aws_cloud9_environment_membership.new_user_membership resource
aws_iam_user.new_user resource
aws_iam_user_login_profile.profile resource
aws_iam_user_policy_attachment.policy_attach_existing resource
aws_iam_user_policy_attachment.policy_attach_new resource
random_id.env resource
aws_iam_policy.cloud9 data source
aws_iam_user.existing_user data source

Contributing

Contributions to this project are welcome. If you have any suggestions, bug fixes, or improvements, please open an issue in this repository.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

AWS Cloud9 environment for development

License:MIT License


Languages

Language:HCL 92.7%Language:Shell 7.3%