https://github.com/mmgil/terraform-mgc-network-vpcs
Magalu Cloud VPC Module
https://github.com/mmgil/terraform-mgc-network-vpcs
magalu magalu-cloud magalucloud module terraform virtual-private-cloud
Last synced: 12 months ago
JSON representation
Magalu Cloud VPC Module
- Host: GitHub
- URL: https://github.com/mmgil/terraform-mgc-network-vpcs
- Owner: mmgil
- Created: 2025-02-25T12:21:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-25T12:35:35.000Z (over 1 year ago)
- Last Synced: 2025-02-25T13:32:35.840Z (over 1 year ago)
- Topics: magalu, magalu-cloud, magalucloud, module, terraform, virtual-private-cloud
- Language: HCL
- Homepage: https://m1cloud.com.br
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# INTRODUCTION
**PROJECT**: IaC (Infrastructure as a Code) with terraform for deploying azure resource group
## What Is Terraform?
Terraform is an infrastructure as code (IaC) tool that allows you to build, change, and version infrastructure safely and efficiently. This includes both low-level components like compute instances, storage, and networking, as well as high-level components like DNS entries and SaaS features.
## What Is MGC Network VPC?
VPC is a virtual network isolated behind of the Magalu Cloud infrastructure. This resource allow you execute yours resources with more security and privacy, with full control over the network environment.
[more](https://docs.magalu.cloud/docs/network/overview)
# NAMING CONVENTIONS
An effective naming convention consists of resource names from important information about each resource. A good name helps you quickly identify the resource's type, associated workload, environment, and the region hosting it.
In our environment we adopt the following convention:
| Business Cost Center (any characters) | Environment (3 characters and 1 number) | Azure Region (4 characters) | Resource Type (5 characters max) | Instance (3 characters) |
| ----------------------------------- | --------------------------------------- | --------------------------- | -------------------------------- | :---------------------: |
Environments possibles:
| Name | Acronym | Description |
| ----------- | ------- | --------------------------------------------------- |
| Production | pro1 | Production Environment |
| Staging | sta1 | Homologation Environment |
| Development | dev1 | Development Environment |
| Shared | sha1 | Shared Environment |
| hub | hub1 | Transit Environment to network resources |
| Spoke | spk1 | Hub Environment to traffic requests to on-premisses |
Magalu Cloud Region (5 characters) according this table:
| ACRONYM | REGION |
| ------- | ----------------- |
| `brse1` | `br-se1` |
| `brne1` | `br-ne1` |
For example, a virtual machine for a business costcenter called cliente01 for a production workload in the Brasil Sudeste Region might be cliente01-pro1-brse1-prj-001.
cliente01-pro1-brse1-prj-001
# INSTALL TERRAFORM
## Linux
### Ubuntu
```bash
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
terraform version
```
### CentOS/RHEL/Oracle Linux
```bash
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install terraform
terraform version
```
## Windows
```powershell
Invoke-WebRequest -Uri https://releases.hashicorp.com/terraform/1.1.9/terraform_1.1.9_windows_amd64.zip -OutFile terraform.zip
Expand-Archive .\terraform.zip -DestinationPath C:\Windows\System32\ -Force
terraform version
```
# AUTHENTICATING IN HASHICORP ENVIRONMENT
We are using hashicorp's SAAS to host the service states. By default, Terraform will obtain an API token and save it in plain text in a local CLI configuration file called credentials.tfrc.json. When you run terraform login, it will explain specifically where it intends to save the API token and give you a chance to cancel if the current configuration is not as desired.
You can get more details about these features from the following links:
[CLI Authentication](https://www.terraform.io/cli/auth)
[terraform login](https://www.terraform.io/cli/commands/login)
[CLI Configuration File](https://www.terraform.io/cli/config/config-file)
You can find the API Token that has already been generated in the environment in our keepass and configure your CLI as follows:
**In Windows**:
```powershell
@"
{
"credentials": {
"app.terraform.io": {
"token": "SEE IN THE KEEPASS OR CONSULTE OURS ADMINS"
}
}
}
"@ | Set-Content ~\AppData\Roaming\terraform.d\credentials.tfrc.json
```
**In Linux**:
```bash
cat < [mgc](#requirement\_mgc) | 0.32.2 |
## Providers
| Name | Version |
|------|---------|
| [mgc](#provider\_mgc) | 0.32.2 |
## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [mgc_network_subnetpools.subnetpool](https://registry.terraform.io/providers/MagaluCloud/mgc/0.32.2/docs/resources/network_subnetpools) | resource |
| [mgc_network_vpcs.vpc](https://registry.terraform.io/providers/MagaluCloud/mgc/0.32.2/docs/resources/network_vpcs) | resource |
| [mgc_network_vpcs_subnets.subnet](https://registry.terraform.io/providers/MagaluCloud/mgc/0.32.2/docs/resources/network_vpcs_subnets) | resource |
| [mgc_availability_zones.availability_zones](https://registry.terraform.io/providers/MagaluCloud/mgc/0.32.2/docs/data-sources/availability_zones) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [project\_name](#input\_project\_name) | [REQUIRED] Name of an existing Project Name | `string` | n/a | yes |
| [sequence](#input\_sequence) | [REQUIRED] Sequence to be used on resource naming. | `number` | `1` | no |
| [subnet\_pools](#input\_subnet\_pools) | [REQUIRED] The address space that is used the virtual network. You can supply more than one address space. CAUTION: Changing the existing address space recalculates all subnets. This action can harm the environment. |
map(
object(
{
## - REQUIRED - SUBNET POO, ENABLED OR NO.
enabled = bool
## REQUIRED - The description of the subnet pool.
description = string
## OPTIONAL - The CIDR block of the subnet pool
cidr = optional(string)
## REQUIRED -
type = optional(string)
## REQUIRED - VPC
vpcs = map(
object(
{
enabled = bool
description = optional(string)
## REQUIRED - Network VPC Subnet
subnets = map(
object(
{
description = optional(string)
enabled = bool
dns_nameservers = optional(list(string))
ip_version = string
mask = number
order = number
}
)
)
}
)
)
}
)
)
| {
"main": {
"cidr": "10.0.0.0/16",
"description": "Managed by Terraform (M1 Cloud).",
"enabled": true,
"vpcs": {
"default": {
"description": "Managed by Terraform.",
"enabled": true,
"subnets": {
"zona1": {
"dns_nameservers": [
"8.8.8.8",
"8.8.4.4"
],
"enabled": true,
"ip_version": "IPv4",
"mask": 22,
"order": 1
}
}
}
}
}
} | no |
## Outputs
| Name | Description |
|------|-------------|
| [resources](#output\_resources) | n/a |
# DOCUMENTATION
Some of this documentation was generated through terraform-docs using the following command:
```bash
docker run --rm --volume "$(pwd):/terraform-docs" quay.io/terraform-docs/terraform-docs:0.16.0 markdown /terraform-docs
```