Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(c9): cloud9 module #91

Merged
merged 5 commits into from
Aug 15, 2023
Merged
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
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"
}
}
}