Skip to content

Commit 0015609

Browse files
authored
Merge pull request #50 from sourcefuse/GH-49
added contribution file and added module usage guide
2 parents b58e9ad + 6ffe84d commit 0015609

File tree

5 files changed

+298
-0
lines changed

5 files changed

+298
-0
lines changed

.github/workflows/update-docs.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,15 @@ jobs:
3636
user-name: ${{ github.actor }}
3737
target-branch: main
3838
commit-message: ${{ github.event.head_commit.message }}
39+
- name: Pushes Module Usage Guide
40+
uses: dmnemec/copy_file_to_another_repo_action@main
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }}
44+
with:
45+
source_file: 'docs/module-usage-guide/README.md'
46+
destination_repo: 'sourcefuse/arc-docs'
47+
destination_folder: 'docs/arc-iac-docs/modules/terraform-aws-arc-ecs/docs/module-usage-guide'
48+
user_email: 'github-actions@github.com'
49+
user_name: ${{ github.actor }}
50+
commit_message: ${{ github.event.head_commit.message }}

CONTRIBUTING.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Contributing to AWS ARC ECS
2+
3+
Thank you for considering contributing to AWS ARC ECS! We appreciate your time and effort.
4+
To ensure a smooth collaboration, please take a moment to review the following guidelines.
5+
6+
## How to Contribute
7+
8+
1. Fork the repository to your own GitHub account.
9+
2. Clone the repository to your local machine.
10+
```bash
11+
git clone https://github.com/<your_organization>/<your_terraform_module>.git
12+
```
13+
3. Create a new branch for your feature / bugfix.
14+
```bash
15+
git checkout -b feature/branch_name
16+
```
17+
4. Make your changes and commit them.
18+
```bash
19+
git commit -m "Your descriptive commit message"
20+
```
21+
5. Push to your forked repository.
22+
```bash
23+
git push origin feature/branch_name
24+
```
25+
6. Open a pull request in the original repository with a clear title and description.
26+
If your pull request addresses an issue, please reference the issue number in the pull request description.
27+
28+
### Git commits
29+
30+
while Contributing or doing git commit please specify the breaking change in your commit message whether its major,minor or patch
31+
32+
For Example
33+
34+
```sh
35+
git commit -m "your commit message #major"
36+
```
37+
By specifying this , it will bump the version and if you don't specify this in your commit message then by default it will consider patch and will bump that accordingly
38+
39+
# Terraform Code Collaboration Guidelines
40+
41+
## File Naming Conventions
42+
43+
1. **Variables File (variables.tf):**
44+
- All variable names should be in snake_case.
45+
- Each variable declaration must contain:
46+
- Description: A brief explanation of the variable's purpose.
47+
- Type: The data type of the variable.
48+
49+
Example:
50+
```hcl
51+
variable "example_variable" {
52+
description = "This is an example variable."
53+
type = string
54+
}
55+
```
56+
57+
2. **Outputs File (outputs.tf):**
58+
- All output names should be in snake_case.
59+
- Each output declaration must contain:
60+
- Description: A brief explanation of the output's purpose.
61+
- Value: The value that will be exposed as the output.
62+
63+
Example:
64+
```hcl
65+
output "example_output" {
66+
description = "This is an example output."
67+
value = module.example_module.example_attribute
68+
}
69+
```
70+
71+
## Resource and Module Naming
72+
73+
1. **Terraform Resources/Modules:**
74+
- Resource and module names should be in snake_case.
75+
- Choose descriptive names that reflect the purpose of the resource or module.
76+
77+
Example:
78+
```hcl
79+
resource "aws_instance" "web_server" {
80+
// ...
81+
}
82+
83+
module "networking" {
84+
// ...
85+
}
86+
```
87+
88+
## General Guidelines
89+
90+
1. **Consistent Formatting:**
91+
- Follow consistent code formatting to enhance readability.
92+
- Use indentation and line breaks appropriately.
93+
94+
2. **Comments:**
95+
- Add comments to explain complex logic, decisions, or any non-trivial code.
96+
- Keep comments up-to-date with the code.
97+
98+
3. **Module Documentation:**
99+
- Include a README.md file within each module directory, explaining its purpose, inputs, and outputs.
100+
- Use inline documentation within the code for complex modules.
101+
102+
4. **Avoid Hardcoding:**
103+
- Minimize hardcoded values; prefer using variables and references for increased flexibility.
104+
105+
5. **Sensitive Information:**
106+
- Do not hardcode sensitive information (e.g., passwords, API keys). Use appropriate methods for securing sensitive data.
107+
108+
6. **Error Handling:**
109+
- Implement proper error handling and consider the impact of potential failures.
110+
111+
## Version Control
112+
113+
1. **Commit Messages:**
114+
- Use descriptive and concise commit messages that explain the purpose of the changes.
115+
116+
2. **Branching:**
117+
- Follow a branching strategy (e.g., feature branches) for better collaboration.
118+
119+
## Pre-commit Hooks
120+
121+
1. **Install `pre-commit`:**
122+
- Install `pre-commit` hooks to automatically check and enforce code formatting, linting, and other pre-defined rules before each commit.
123+
124+
Example:
125+
```bash
126+
brew install pre-commit (for mac users)
127+
```
128+
```bash
129+
pre-commit run -a
130+
```
131+
132+
This ensures that your code adheres to the defined standards before being committed, reducing the likelihood of introducing issues into the repository.
133+
134+
## Code Style
135+
136+
Please follow the Terraform language conventions and formatting guidelines. Consider using an editor with Terraform support or a linter to ensure adherence to the style.
137+
138+
## Testing
139+
140+
!!! This section is a work-in-progress, as we are starting to adopt testing using Terratest. !!!
141+
142+
Before submitting a pull request, ensure that your changes pass all tests. If applicable, add new tests to cover your changes.
143+
144+
## Documentation
145+
146+
Keep the module documentation up-to-date. If you add new features or change existing functionality, update the [README](README.md) and any relevant documentation files.
147+
148+
## Security and Compliance Checks
149+
150+
GitHub Actions are in place to perform security and compliance checks. Please make sure your changes pass these checks before submitting a pull request.
151+
152+
## Licensing
153+
154+
By contributing, you agree that your contributions will be licensed under the project's [LICENSE](LICENSE).

docs/module-usage-guide/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Terraform AWS ARC ECS Module Usage Guide
2+
3+
## Introduction
4+
5+
### Purpose of the Document
6+
7+
This document provides guidelines and instructions for users looking to implement the Terraform AWS ARC ECS module for setting up and running a production ready ECS cluster.
8+
9+
### Module Overview
10+
11+
The [Terraform AWS ARC ECS](https://github.com/sourcefuse/terraform-aws-arc-ecs) module provides a secure and modular foundation for deploying ECS clusters on AWS.
12+
13+
### Prerequisites
14+
15+
Before using this module, ensure you have the following:
16+
17+
- AWS credentials configured.
18+
- Terraform installed.
19+
- A working knowledge of AWS VPC, ECS and Terraform concepts.
20+
21+
## Getting Started
22+
23+
### Module Source
24+
25+
To use the module in your Terraform configuration, include the following source block:
26+
27+
```hcl
28+
module "arc-ecs" {
29+
source = "sourcefuse/arc-ecs/aws"
30+
version = "1.5.0"
31+
# insert the 6 required variables here
32+
}
33+
```
34+
35+
Refer to the [Terraform Registry](https://registry.terraform.io/modules/sourcefuse/arc-ecs/aws/latest) for the latest version.
36+
37+
### Integration with Existing Terraform Configurations
38+
39+
Integrate the module with your existing Terraform mono repo configuration, follow the steps below:
40+
41+
1. Create a new folder in `terraform/` named `ecs`.
42+
2. Create the required files, see the [examples](https://github.com/sourcefuse/terraform-aws-arc-ecs/tree/main/example) to base off of.
43+
3. Configure with your backend
44+
- Create the environment backend configuration file: `config.<environment>.hcl`
45+
- **region**: Where the backend resides
46+
- **key**: `<working_directory>/terraform.tfstate`
47+
- **bucket**: Bucket name where the terraform state will reside
48+
- **dynamodb_table**: Lock table so there are not duplicate tfplans in the mix
49+
- **encrypt**: Encrypt all traffic to and from the backend
50+
51+
### Required AWS Permissions
52+
53+
Ensure that the AWS credentials used to execute Terraform have the necessary permissions to create, list and modify:
54+
55+
- ECS cluster
56+
- Application load balancer
57+
- ACM
58+
- SSM Parameters
59+
- Cloudwatch Log groups
60+
- IAM roles and policies
61+
62+
## Module Configuration
63+
64+
### Input Variables
65+
66+
For a list of input variables, see the README [Inputs](https://github.com/sourcefuse/terraform-aws-arc-ecs?tab=readme-ov-file#inputs) section.
67+
68+
### Output Values
69+
70+
For a list of outputs, see the README [Outputs](https://github.com/sourcefuse/terraform-aws-arc-ecs?tab=readme-ov-file#outputs) section.
71+
72+
## Module Usage
73+
74+
### Basic Usage
75+
76+
For basic usage, see the [example](https://github.com/sourcefuse/terraform-aws-arc-ecs/tree/main/example) folder.
77+
78+
This example will create:
79+
80+
- An ECS Cluster with Fargate launch type.
81+
- Application Load Balancer with default port 80 to 443 redirect.
82+
- Health Check Service: A vanilla HTTP echo service serving as the default target group for the load balancer to ensure core infrastructure, networking, security groups, etc. are configured correctly.
83+
- Task Execution IAM Role: Used by downstream services for task execution.
84+
- ACM Certificate: Generates a certificate specific to the ALB.
85+
- Tags/SSM Params: The module tags resources and outputs SSM params for ECS services to reference when deploying into the cluster
86+
87+
### Tips and Recommendations
88+
89+
- The module focuses on provisioning an ECS Cluster using Fargate launch type, an ALB with a default port redirect, a health check service, a task execution IAM role, and an ACM certificate for secure communication. The convention-based approach enables downstream services to easily attach to the ECS Fargate cluster. Adjust the configuration parameters as needed for your specific use case.
90+
91+
## Troubleshooting
92+
93+
### Reporting Issues
94+
95+
If you encounter a bug or issue, please report it on the [GitHub repository](https://github.com/sourcefuse/terraform-aws-arc-ecs/issues).
96+
97+
## Security Considerations
98+
99+
### AWS VPC
100+
101+
Understand the security considerations related to ECS clusters on AWS when using this module.
102+
103+
### Best Practices for AWS ECS
104+
105+
Follow best practices to ensure secure ECS configurations:
106+
107+
- [ECS security on AWS](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/security.html)
108+
109+
## Contributing and Community Support
110+
111+
### Contributing Guidelines
112+
113+
Contribute to the module by following the guidelines outlined in the [CONTRIBUTING.md](https://github.com/sourcefuse/terraform-aws-arc-ecs/blob/main/CONTRIBUTING.md) file.
114+
115+
### Reporting Bugs and Issues
116+
117+
If you find a bug or issue, report it on the [GitHub repository](https://github.com/sourcefuse/terraform-aws-arc-ecs/issues).
118+
119+
## License
120+
121+
### License Information
122+
123+
This module is licensed under the Apache 2.0 license. Refer to the [LICENSE](https://github.com/sourcefuse/terraform-aws-arc-ecs/blob/main/LICENSE) file for more details.
124+
125+
### Open Source Contribution
126+
127+
Contribute to open source by using and enhancing this module. Your contributions are welcome!

modules/alb/.terraform.lock.hcl

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/health-check/.terraform.lock.hcl

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)