Skip to content

Commit

Permalink
feat(c9): cloud9 module (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-ook authored Aug 15, 2023
1 parent 8292fb1 commit 7c60443
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 0 deletions.
Binary file added images/aws-c9-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions modules/cloud9/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# AWS Cloud9
[AWS Cloud9](https://aws.amazon.com/cloud9/) is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser. It includes a code editor, debugger, and terminal. Cloud9 comes prepackaged with essential tools for popular programming languages, including JavaScript, Python, PHP, and more, so you don’t need to install files or configure your development machine to start new projects. Since your Cloud9 IDE is cloud-based, you can work on your projects from your office, home, or anywhere using an internet-connected machine. Cloud9 also provides a seamless experience for developing serverless applications enabling you to easily define resources, debug, and switch between local and remote execution of serverless applications. Fore more details, please refer to [this page](https://aws.amazon.com/cloud9/details/).

![aws-c9-editor](../../images/aws-c9-editor.png)

## Setup
### Prerequisites
This module requires *terraform*. If you don't have the terraform tool in your environment, go to the main [page](https://github.com/Young-ook/terraform-aws-ssm) of this repository and follow the installation instructions.

### Quickstart
```
module "vpc" {
source = "Young-ook/vpc/aws"
}
module "cloud9" {
source = "Young-ook/ssm/aws//modules/cloud9"
subnet = values(module.vpc.subnets["public"])[0]
}
```

Run terraform:
```
terraform init
terraform apply
```

# Additional Resources
13 changes: 13 additions & 0 deletions modules/cloud9/default.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### default values

module "aws" {
source = "Young-ook/spinnaker/aws//modules/aws-partitions"
}

locals {
default_workspace = {
instance_type = "t2.micro"
connection_type = "CONNECT_SSM" # allowed values: CONNECT_SSH, CONNECT_SSM
automatic_stop_time_minutes = 30
}
}
14 changes: 14 additions & 0 deletions modules/cloud9/labels.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### frigga name
module "frigga" {
source = "Young-ook/spinnaker/aws//modules/frigga"
version = "3.0.0"
name = var.name == null || var.name == "" ? "c9" : var.name
petname = var.name == null || var.name == "" ? true : false
}

locals {
name = module.frigga.name
default-tags = merge(
{ "terraform.io" = "managed" },
)
}
16 changes: 16 additions & 0 deletions modules/cloud9/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### integrated development environment
resource "aws_cloud9_environment_ec2" "ide" {
name = local.name
tags = merge(local.default-tags, var.tags)
instance_type = lookup(var.workspace, "instance_type", local.default_workspace.instance_type)
automatic_stop_time_minutes = lookup(var.workspace, "automatic_stop_time_minutes", local.default_workspace.automatic_stop_time_minutes)
connection_type = lookup(var.workspace, "connection_type", local.default_workspace.connection_type)
subnet_id = var.subnet
}

data "aws_instance" "ide" {
filter {
name = "tag:aws:cloud9:environment"
values = [aws_cloud9_environment_ec2.ide.id]
}
}
6 changes: 6 additions & 0 deletions modules/cloud9/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### output variables

output "cloud9_url" {
description = "URL to open AWS Cloud9 IDE"
value = "https://${module.aws.region.name}.console.aws.amazon.com/cloud9/ide/${aws_cloud9_environment_ec2.ide.id}"
}
17 changes: 17 additions & 0 deletions modules/cloud9/tests/defaults/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_providers {
test = {
source = "terraform.io/builtin/test"
}
}
}

module "vpc" {
source = "Young-ook/vpc/aws"
version = "1.0.5"
}

module "main" {
source = "../.."
subnet = values(module.vpc.subnets["public"])[0]
}
26 changes: 26 additions & 0 deletions modules/cloud9/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### network
variable "subnet" {
description = "The subnet ID to deploy your cloud9 environment"
type = string
default = null
}

### workspace
variable "workspace" {
description = "Cloud9 workspace configuration"
default = {}
}

### description
variable "name" {
description = "Resource name of your cloud id environment"
type = string
default = null
}

### tags
variable "tags" {
description = "The key-value maps for tagging"
type = map(string)
default = {}
}
13 changes: 13 additions & 0 deletions modules/cloud9/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## requirements

terraform {
# Terraform test is an experimental features introduced in Terraform CLI v0.15.0.
# So, you'll need to upgrade to v0.15.0 or later to use terraform test.
required_version = ">= 0.15"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0"
}
}
}

0 comments on commit 7c60443

Please sign in to comment.