Skip to content

Commit d3b8140

Browse files
committed
The first commit
0 parents  commit d3b8140

File tree

9 files changed

+252
-0
lines changed

9 files changed

+252
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
indent_size = 4
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.{yaml,yml,json,tf,tfvars}]
15+
indent_size = 2
16+
17+
[*.md]
18+
trim_trailing_whitespace = false

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
*.log
2+
3+
# Terraform files #
4+
###################
5+
.terraform/
6+
.terraform.lock.hcl
7+
*.tfvars
8+
9+
# IDE and editor specific files #
10+
#################################
11+
nbproject
12+
.idea
13+
.vscode
14+
.phpstorm.meta.php
15+
_ide_helper.php
16+
17+
# OS generated files #
18+
######################
19+
.DS_Store
20+
.DS_Store?
21+
._*
22+
.Spotlight-V100
23+
.Trashes
24+
Icon?
25+
ehthumbs.db
26+
Thumbs.db
27+
*.mo

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
8+
9+
10+
## [Unreleased] - YYYY-MM-DD
11+
12+
### Added
13+
- Nothing
14+
15+
### Changed
16+
- Nothing
17+
18+
### Deprecated
19+
- Nothing
20+
21+
### Removed
22+
- Nothing
23+
24+
### Fixed
25+
- Nothing
26+
27+
### Security
28+
- Nothing
29+
30+
31+
32+
33+
## 0.1.0 - 2021-08-10
34+
35+
First release
36+
37+
38+
39+
40+
[Unreleased]: https://github.com/rabiloo/terraform-aws-ecs/compare/v0.1.0...master

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021 Rabiloo Co., Ltd
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19+
OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# AWS ECS Terraform module
2+
3+
Terraform module which creates ECS cluster resources on AWS.
4+
5+
## TODO
6+
7+
- [ ] Update README.md
8+
- [ ] Add examples
9+
- [ ] Add Github Wrokflows
10+
11+
## Usage
12+
13+
```hcl
14+
module "php" {
15+
source = "rabiloo/ecs/aws"
16+
version = "~> 0.1.0"
17+
18+
name = "app-ecs-cluster"
19+
capacity_providers = ["FARGATE", "FARGATE_SPOT"]
20+
default_capacity_provider_strategy = [
21+
{ capacity_provider = "FARGATE" },
22+
]
23+
tags = {
24+
Owner = "user"
25+
Service = "app-name"
26+
}
27+
}
28+
```
29+
30+
## Requirements
31+
32+
| Name | Version |
33+
|------|---------|
34+
| Terraform | `~> 1.0` |
35+
36+
## Providers
37+
38+
| Name | Version |
39+
|------|---------|
40+
| aws | `~> 3.52` |
41+
42+
## Resources
43+
44+
45+
46+
## Inputs
47+
48+
## Outputs
49+
50+
## Contributing
51+
52+
All code contributions must go through a pull request and approved by a core developer before being merged.
53+
This is to ensure proper review of all the code.
54+
55+
Fork the project, create a feature branch, and send a pull request.
56+
57+
If you would like to help take a look at the [list of issues](https://github.com/rabiloo/terraform-aws-ecs/issues).
58+
59+
## License
60+
61+
This project is released under the MIT License.
62+
Copyright © 2021 [Rabiloo Co., Ltd](https://rabiloo.com)
63+
Please see [License File](LICENSE) for more information.

main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
resource "aws_ecs_cluster" "this" {
2+
name = var.name
3+
4+
capacity_providers = var.capacity_providers
5+
6+
dynamic "default_capacity_provider_strategy" {
7+
for_each = var.default_capacity_provider_strategy
8+
iterator = strategy
9+
10+
content {
11+
capacity_provider = strategy.value["capacity_provider"]
12+
weight = lookup(strategy.value, "weight", null)
13+
base = lookup(strategy.value, "base", null)
14+
}
15+
}
16+
17+
setting {
18+
name = "containerInsights"
19+
value = var.container_insights ? "enabled" : "disabled"
20+
}
21+
22+
tags = merge({ Name = var.name }, var.tags)
23+
}

outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
output "ecs_cluster_id" {
2+
description = "The ID of the ECS Cluster"
3+
value = aws_ecs_cluster.this.id
4+
}
5+
6+
output "ecs_cluster_arn" {
7+
description = "The ARN of the ECS Cluster"
8+
value = aws_ecs_cluster.this.arn
9+
}
10+
11+
output "ecs_cluster_name" {
12+
description = "The name of the ECS cluster"
13+
value = var.name
14+
}

variables.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
variable "name" {
2+
description = "The name of the ECS cluster"
3+
type = string
4+
5+
validation {
6+
conditiion = var.name != ""
7+
error_message = "The name MUST be not empty."
8+
}
9+
10+
validation {
11+
condition = var.name == replace(var.name, "/[^a-zA-Z0-9-_]+/", "")
12+
error_message = "The name MUST be alphanumeric and can contain dashes and underscores."
13+
}
14+
}
15+
16+
variable "capacity_providers" {
17+
description = "List of short names of one or more capacity providers to associate with the cluster. Valid values also include FARGATE and FARGATE_SPOT."
18+
type = list(string)
19+
default = []
20+
}
21+
22+
variable "default_capacity_provider_strategy" {
23+
description = "The capacity provider strategy to use by default for the cluster. Can be one or more."
24+
type = list(map(any))
25+
default = []
26+
}
27+
28+
variable "container_insights" {
29+
description = "Controls if ECS Cluster has container insights enabled"
30+
type = bool
31+
default = false
32+
}
33+
34+
variable "tags" {
35+
description = "The tags for ECS Cluster"
36+
type = map(string)
37+
default = {}
38+
}

versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = "~> 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 3.52"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)