Code Monkey home page Code Monkey logo

terraform-azurerm-aci's Introduction

Azure container instances group

Changelog Notice Apache V2 License TF Registry

Azure module to generate a Container instances group.

Global versioning rule for Claranet Azure modules

Module version Terraform version AzureRM version
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

module "azure_region" {
  source  = "claranet/regions/azurerm"
  version = "x.x.x"

  azure_region = var.azure_region
}

module "rg" {
  source  = "claranet/rg/azurerm"
  version = "x.x.x"

  location    = module.azure_region.location
  client_name = var.client_name
  environment = var.environment
  stack       = var.stack
}

module "logs" {
  source  = "claranet/run/azurerm//modules/logs"
  version = "x.x.x"

  client_name         = var.client_name
  environment         = var.environment
  stack               = var.stack
  location            = module.azure_region.location
  location_short      = module.azure_region.location_short
  resource_group_name = module.rg.resource_group_name
}

module "acr" {
  source  = "claranet/acr/azurerm"
  version = "x.x.x"

  location            = module.azure_region.location
  location_short      = module.azure_region.location_short
  resource_group_name = module.rg.resource_group_name
  sku                 = "Standard"

  client_name = var.client_name
  environment = var.environment
  stack       = var.stack

  logs_destinations_ids = [
    module.logs.logs_storage_account_id,
    module.logs.log_analytics_workspace_id
  ]

  extra_tags = {
    foo = "bar"
  }
}

module "aci" {
  source  = "claranet/aci/azurerm"
  version = "x.x.x"

  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  client_name    = var.client_name
  environment    = var.environment
  stack          = var.stack

  resource_group_name = module.rg.resource_group_name

  restart_policy = "OnFailure"

  containers_config = [
    {
      name   = "aci-example"
      image  = "${module.acr.login_server}/samples/nginx:latest"
      cpu    = 1
      memory = 2

      ports = [{
        port     = 80
        protocol = "TCP"
      }]
    }
  ]

  registry_credential = {
    username = module.acr.admin_username
    password = module.acr.admin_password
    server   = module.acr.login_server
  }

  logs_destinations_ids = [
    module.logs.logs_storage_account_id,
    module.logs.log_analytics_workspace_id
  ]

  extra_tags = {
    foo = "bar"
  }
}

Providers

Name Version
azurecaf ~> 1.2, >= 1.2.22
azurerm ~> 3.71

Modules

Name Source Version
diagnostics claranet/diagnostic-settings/azurerm ~> 6.5.0

Resources

Name Type
azurerm_container_group.aci resource
azurecaf_name.aci data source

Inputs

Name Description Type Default Required
client_name Client name/account used in naming string n/a yes
containers_config Containers configurations.
list(object({
name = string

image = string
cpu = number
memory = number

environment_variables = optional(map(string))
secure_environment_variables = optional(map(string))
commands = optional(list(string))

ports = list(object({
port = number
protocol = string
}))

volume = optional(list(object({
name = string
mount_path = string
read_only = optional(bool)
empty_dir = optional(bool)
storage_account_name = optional(string)
storage_account_key = optional(string)
share_name = optional(string)
secret = optional(map(any))
})), [])

readiness_probe = optional(object({
exec = optional(list(string))
http_get = optional(object({
path = optional(string)
port = optional(number)
scheme = optional(string)
http_headers = optional(map(string))
}))
initial_delay_seconds = optional(number)
period_seconds = optional(number)
failure_threshold = optional(number)
success_threshold = optional(number)
timeout_seconds = optional(number)
}))

liveness_probe = optional(object({
exec = optional(list(string))
http_get = optional(object({
path = optional(string)
port = optional(number)
scheme = optional(string)
http_headers = optional(map(string))
}))
initial_delay_seconds = optional(number)
period_seconds = optional(number)
failure_threshold = optional(number)
success_threshold = optional(number)
timeout_seconds = optional(number)
}))

}))
n/a yes
custom_diagnostic_settings_name Custom name of the diagnostics settings, name will be 'default' if not set. string "default" no
custom_name Custom Azure Container Instances group name, generated if not set string "" no
default_tags_enabled Option to enable or disable default tags. bool true no
dns_config DNS configuration to apply to containers.
object({
nameservers = list(string)
search_domains = optional(list(string))
options = optional(list(string))
})
null no
dns_name_label ACI Custom DNS name label used when container is public. string null no
dns_name_label_reuse_policy The value representing the security enum. Noreuse, ResourceGroupReuse, SubscriptionReuse, TenantReuse or Unsecure. Defaults to Unsecure. string "Unsecure" no
environment Project environment string n/a yes
extra_tags Additional tags to associate with your Azure Container Instances group. map(string) {} no
identity Map with identity block information.
object({
type = optional(string, "SystemAssigned")
identity_ids = optional(list(string))
})
{} no
init_containers initContainer configuration.
list(object({
name = string
image = string
environment_variables = optional(map(string), {})
secure_environment_variables = optional(map(string), {})
commands = optional(list(string), [])
volume = optional(list(object({
name = string
mount_path = string
read_only = optional(bool)
empty_dir = optional(bool)
storage_account_name = optional(string)
storage_account_key = optional(string)
share_name = optional(string)
secret = optional(map(any))
})), [])
security = optional(object({
privilege_enabled = bool
}), null)
}))
[] no
location Azure region to use string n/a yes
location_short Short string for Azure location string n/a yes
logs_categories Log categories to send to destinations. list(string) null no
logs_destinations_ids List of destination resources IDs for logs diagnostic destination.
Can be Storage Account, Log Analytics Workspace and Event Hub. No more than one of each can be set.
If you want to specify an Azure EventHub to send logs and metrics to, you need to provide a formated string with both the EventHub Namespace authorization send ID and the EventHub name (name of the queue to use in the Namespace) separated by the `
` character. list(string) n/a
logs_metrics_categories Metrics categories to send to destinations. list(string) null no
name_prefix Optional prefix for the generated name string "" no
name_suffix Optional suffix for the generated name string "" no
os_type The OS for the container group. Allowed values are Linux and Windows. Changing this forces a new resource to be created. string "Linux" no
registry_credential A registry_credential object as documented below. Changing this forces a new resource to be created.
object({
username = string
password = string
server = string
})
null no
resource_group_name Name of the resource group string n/a yes
restart_policy Restart policy for the container group. Allowed values are Always, Never, OnFailure. Changing this forces a new resource to be created. string "Always" no
stack Project stack name string n/a yes
subnet_ids Subnet IDs of the private network profile of the container.
Mandatory when VNet integration is enabled.
list(string) null no
use_caf_naming Use the Azure CAF naming provider to generate default resource name. custom_name override this if set. Legacy default name is used if this is set to false. bool true no
vnet_integration_enabled Allow to enable Vnet integration. bool false no

Outputs

Name Description
aci_fqdn The FQDN of the container group derived from dns_name_label.
aci_id Azure container instance group ID
aci_identity_principal_id ACI identity principal ID.
aci_ip_address The IP address allocated to the container instance group.

Related documentation

Microsoft Azure documentation: docs.microsoft.com/en-us/azure/container-instances/container-instances-overview

terraform-azurerm-aci's People

Contributors

alanbty avatar bzspi avatar fdmsantos avatar jmapro avatar maxpoullain avatar oleksiimorozenko avatar rossifumax avatar shr3ps avatar zfiel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-azurerm-aci's Issues

Invalid module version syntax

Hey!

When cloning this repo and running terraform init in vnet_integration folder the command fails with the error:

Initializing modules...
╷
│ Error: Invalid version constraint
│ 
│ Module "aci" (declared at modules.tf line 96) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵
╷
│ Error: Invalid version constraint
│ 
│ Module "acr" (declared at modules.tf line 73) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵
╷
│ Error: Invalid version constraint
│ 
│ Module "azure_region" (declared at modules.tf line 5) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵
╷
│ Error: Invalid version constraint
│ 
│ Module "logs" (declared at modules.tf line 61) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵
╷
│ Error: Invalid version constraint
│ 
│ Module "rg" (declared at modules.tf line 12) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵
╷
│ Error: Invalid version constraint
│ 
│ Module "subnet" (declared at modules.tf line 37) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵
╷
│ Error: Invalid version constraint
│ 
│ Module "vnet" (declared at modules.tf line 23) has invalid version constraint "x.x.x": Malformed constraint: x.x.x.
╵

[FEAT] Add ability to Control whether resources should be created

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I would like have a variable that gives me the possibility do delete everything.
For example:

  • Add new bool variable named create with default value to true.
  • In all resources add count expression like this: count = var.create ? 1 : 0 (To resources with for_each expression, needs to be different)

With that, when i want to destroy everything, i only need to change the var.create variable to false.

Use Cases:

  • In dev environment i would like to destroy all resources created by this module due cost optimization. But i dont want destroy all resources in my terraform project, because some resources like Storage Containers, File Shares contains data, so terraform destroy is not option.

I can submit PR to add this feature but i would like know if this is a feature you want to add before starting development.

New or Affected Resource(s)/Data Source(s)

Probably All Resources will be affected

Potential Terraform Configuration

variable "create" {
  description = "Controls whether resources should be created"
  type        = bool
  default     = true
}

For all resources (except the resources that have for_each) add:
count = var.create ? 1 : 0

Also we need to change resources referencing, because now the resources will be indexed. Example:

TO get Container Group Name will change from azurerm_container_group.aci.name to azurerm_container_group.aci[0].name

References

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.