Módulo Terraform para criação e gerenciamento de Container Registries na Magalu Cloud com funcionalidades completas para DevOps e CI/CD.
sequenceDiagram
participant User
participant Terraform
participant MagaluCloud
User->>Terraform: Fornece variáveis (API Key, region, nomes)
Terraform->>MagaluCloud: Provisiona Container Registry
Terraform->>MagaluCloud: (Opcional) Consulta registries, repositórios, imagens, credenciais
MagaluCloud-->>Terraform: Retorna dados dos recursos
Terraform-->>User: Exibe outputs (IDs, credenciais, análises, alertas)
module "container_registry" {
source = "https://github.com/terraform-mgc-modules/mgc-container-registry?ref=v1.0.0"
container_registry_name = "meu-registry-app"
}
output "registry_id" {
value = module.container_registry.container_registry_id
}
module "container_registry" {
source = "https://github.com/terraform-mgc-modules/mgc-container-registry?ref=v1.0.0"
container_registry_name = "producao-apps"
enable_credentials_output = true
enable_repositories_data = true
}
output "registry_credentials" {
value = module.container_registry.container_credentials
sensitive = true
}
Este módulo inclui exemplos práticos prontos para uso:
- Exemplo Simples - Registry básico para desenvolvimento.
- Exemplo Completo - Configuração avançada com 3 registries demonstrando todas as funcionalidades.
# Exemplo simples
cd examples/simple
terraform init
terraform plan
terraform apply
# Exemplo completo
cd examples/complete
terraform init
terraform plan
terraform apply
📦 Requirements & Providers
Name | Version |
---|---|
mgc | 0.33.0 |
Name | Version |
---|---|
mgc | 0.33.0 |
Name | Type |
---|---|
mgc_container_registries.registry | resource |
mgc_container_credentials.creds | data source |
mgc_container_images.images | data source |
mgc_container_registries.all_registries | data source |
mgc_container_repositories.repositories | data source |
🔧 Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
container_registry_name | The name of the container registry to create. | string |
"my-container-registry" |
no |
enable_credentials_output | Whether to output container registry credentials. Set to true if you need access credentials. | bool |
false |
no |
enable_images_data | Whether to fetch images data from the specified repository. Requires repository_name to be set. | bool |
false |
no |
enable_registries_list | Whether to fetch a list of all container registries. Useful for reference or comparison. | bool |
false |
no |
enable_repositories_data | Whether to fetch repositories data from the created registry. | bool |
false |
no |
mgc_api_key | API Key da Magalu Cloud para testes | string |
n/a | yes |
mgc_region | Região da Magalu Cloud (ex: br-se1) | string |
"br-se1" |
no |
repository_name | Name of a specific repository to fetch images data from. Leave null if not needed. | string |
null |
no |
📤 Outputs
Name | Description | Availability |
---|---|---|
all_registries | List of all container registries in the account | When enable_registries_list = true |
container_credentials | Container registry authentication credentials | When enable_credentials_output = true |
container_registry_created_at | The timestamp when the registry was created | When enable_registries_list = true |
container_registry_id | The unique identifier of the created container registry | Always |
container_registry_name | The name of the created container registry | Always |
container_registry_storage_usage_bytes | The storage usage in bytes of the registry | When enable_registries_list = true |
container_registry_updated_at | The timestamp when the registry was last updated | When enable_registries_list = true |
images | List of images in the specified repository | When enable_images_data = true and repository_name set |
repositories | List of repositories in the created registry | When enable_repositories_data = true |
- Requisitos - Requirements e providers
- Variáveis - Inputs disponíveis
- Outputs - Outputs do módulo
- API Keys - Como configurar autenticação
- Comandos CLI - Comandos MGC CLI para Container Registry
{
username = "string"
email = "string"
password = "string" # sensível
}
[
{
id = "string"
name = "string"
created_at = "string"
updated_at = "string"
storage_usage_bytes = number
}
]
module "ci_registry" {
source = "github.com/nataliagranato/mgc-container-registry"
container_registry_name = "ci-cd-apps"
enable_credentials_output = true
}
# Configure GitHub Actions
resource "github_actions_secret" "registry_username" {
repository = "meu-repo"
secret_name = "REGISTRY_USERNAME"
plaintext_value = module.ci_registry.container_credentials.username
}
module "dev_registry" {
source = "github.com/nataliagranato/mgc-container-registry"
container_registry_name = "dev-apps"
}
module "prod_registry" {
source = "github.com/nataliagranato/mgc-container-registry"
container_registry_name = "prod-apps"
enable_credentials_output = true
}
- Terraform >= 0.14
- Provider MGC >= 0.33.0
- API Key da Magalu Cloud com permissões Container Registry
terraform {
required_providers {
mgc = {
source = "magalucloud/mgc"
version = "~> 0.33.0"
}
}
}
provider "mgc" {
api_key = var.mgc_api_key
region = "br-se1"
}
Consulte CONTRIBUTING.md para diretrizes de contribuição.
Para reportar vulnerabilidades, veja SECURITY.md.
Este projeto está sob a licença especificada no arquivo LICENSE.
Feito com ❤️ por Natália Granato