Skip to content

Commit 693b74a

Browse files
authored
Merge pull request #1 from kewalaka/feat/container-apps
initial version for container apps
2 parents af5558d + 1acfeb4 commit 693b74a

File tree

21 files changed

+1068
-34
lines changed

21 files changed

+1068
-34
lines changed

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"image": "mcr.microsoft.com/azterraform:latest",
3+
"runArgs": [
4+
"--cap-add=SYS_PTRACE",
5+
"--security-opt",
6+
"seccomp=unconfined",
7+
"--init",
8+
"--network=host"
9+
],
10+
"mounts": [
11+
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
12+
],
13+
"customizations": {
14+
"vscode": {
15+
"settings": {
16+
"go.toolsManagement.checkForUpdates": "local",
17+
"go.useLanguageServer": true,
18+
"go.goroot": "/usr/local/go"
19+
},
20+
"extensions": [
21+
"hashicorp.terraform",
22+
"golang.Go"
23+
]
24+
}
25+
}
26+
}

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ crash.log
1010
crash.*.log
1111

1212
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
13-
# password, private keys, and other secrets. These should not be part of version
14-
# control as they are data points which are potentially sensitive and subject
13+
# password, private keys, and other secrets. These should not be part of version
14+
# control as they are data points which are potentially sensitive and subject
1515
# to change depending on the environment.
1616
*.tfvars
1717
*.tfvars.json
@@ -26,12 +26,12 @@ override.tf.json
2626
# Include override files you do wish to add to version control using negated pattern
2727
# !example_override.tf
2828

29-
# Ignore Terraform lock file
30-
.terraform.lock.hcl
31-
3229
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
3330
# example: *tfplan*
3431

3532
# Ignore CLI configuration files
3633
.terraformrc
3734
terraform.rc
35+
36+
# lock files
37+
**/.terraform.lock.hcl

.terraform-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ settings:
6060
hide-empty: false
6161
html: true
6262
indent: 2
63-
lockfile: false
63+
lockfile: true
6464
read-comments: true
6565
required: true
6666
sensitive: true

.vscode/extensions.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"recommendations": [
33
"hashicorp.terraform",
4-
"EditorConfig.EditorConfig"
4+
"editorconfig.editorconfig",
5+
"azapi-vscode.azapi",
6+
"ms-vscode-remote.remote-wsl",
7+
"ms-vscode-remote.remote-containers"
58
]
6-
}
9+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
22
"editor.bracketPairColorization.enabled": true,
3-
}
3+
"git.enableCommitSigning": true,
4+
}

README.md

Lines changed: 259 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<!-- BEGIN_TF_DOCS -->
2-
# terraform-azurerm-avm-template
2+
# terraform-azurerm-avm-res-container-apps
33

4-
This is a template repo for Terraform Azure Verified Modules.
4+
This is a repo for Container Apps in the style of Azure Verified Modules (AVM), it is an 'unofficial' example that has been used for learning AVM.
5+
6+
Note this uses the AZAPI provider because of support missing within the AzureRM provider for [workload profiles](https://github.com/hashicorp/terraform-provider-azurerm/issues/21747).
7+
8+
Once required functionality is available within AzureRM, [azapi2azurerm](https://github.com/Azure/azapi2azurerm) can be used to convert this code.
9+
10+
This project includes [examples](./examples/) showing default settings and an example from Microsoft Learn illustrating Dapr.
511

612
Things to do:
713

@@ -20,7 +26,9 @@ Things to do:
2026

2127
The following requirements are needed by this module:
2228

23-
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (>= 1.0.0)
29+
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (>= 1.3.0)
30+
31+
- <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) (1.9.0)
2432

2533
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.71.0)
2634

@@ -30,6 +38,8 @@ The following requirements are needed by this module:
3038

3139
The following providers are used by this module:
3240

41+
- <a name="provider_azapi"></a> [azapi](#provider\_azapi) (1.9.0)
42+
3343
- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (>= 3.71.0)
3444

3545
- <a name="provider_random"></a> [random](#provider\_random) (>= 3.5.0)
@@ -38,14 +48,222 @@ The following providers are used by this module:
3848

3949
The following resources are used by this module:
4050

51+
- [azapi_resource.container_app](https://registry.terraform.io/providers/Azure/azapi/1.9.0/docs/resources/resource) (resource)
4152
- [azurerm_resource_group_template_deployment.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group_template_deployment) (resource)
4253
- [random_id.telem](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) (resource)
54+
- [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source)
4355

4456
<!-- markdownlint-disable MD013 -->
4557
## Required Inputs
4658

4759
The following input variables are required:
4860

61+
### <a name="input_container_app_environment_resource_id"></a> [container\_app\_environment\_resource\_id](#input\_container\_app\_environment\_resource\_id)
62+
63+
Description: Resource ID of environment.
64+
65+
Type: `string`
66+
67+
### <a name="input_container_apps"></a> [container\_apps](#input\_container\_apps)
68+
69+
Description: Specifies the container apps in the managed environment.
70+
71+
Type:
72+
73+
```hcl
74+
list(object({
75+
name = string
76+
revision_mode = optional(string, "Single")
77+
78+
dapr = optional(object({
79+
appId = optional(string)
80+
appPort = optional(number)
81+
appProtocol = optional(string)
82+
enableApiLogging = optional(bool)
83+
enabled = optional(bool)
84+
httpMaxRequestSize = optional(number)
85+
httpReadBufferSize = optional(number)
86+
logLevel = optional(string)
87+
}))
88+
ingress = optional(object({
89+
allowInsecure = optional(bool)
90+
clientCertificateMode = optional(string)
91+
corsPolicy = optional(object({
92+
allowCredentials = optional(bool)
93+
allowedHeaders = optional(list(string))
94+
allowedMethods = optional(list(string))
95+
allowedOrigins = optional(list(string))
96+
exposeHeaders = optional(list(string))
97+
maxAge = optional(number)
98+
}))
99+
customDomains = optional(list(object({
100+
bindingType = optional(string)
101+
certificateId = optional(string)
102+
name = optional(string)
103+
})))
104+
exposedPort = optional(number)
105+
external = optional(bool)
106+
ipSecurityRestrictions = optional(list(object({
107+
action = optional(string)
108+
description = optional(string)
109+
ipAddressRange = optional(string)
110+
name = optional(string)
111+
})))
112+
stickySessions = optional(object({
113+
affinity = optional(string)
114+
}))
115+
targetPort = optional(number)
116+
traffic = optional(list(object({
117+
label = optional(string)
118+
latestRevision = optional(bool)
119+
revisionName = optional(string)
120+
weight = optional(number)
121+
})))
122+
transport = optional(string)
123+
}))
124+
maxInactiveRevisions = optional(number)
125+
registries = optional(list(object({
126+
identity = optional(string)
127+
passwordSecretRef = optional(string)
128+
server = optional(string)
129+
username = optional(string)
130+
})))
131+
secrets = optional(list(object({
132+
identity = optional(string)
133+
keyVaultUrl = optional(string)
134+
name = string
135+
value = string
136+
})))
137+
service = optional(object({
138+
type = optional(string)
139+
}))
140+
141+
template = object({
142+
containers = list(object({
143+
args = optional(list(string))
144+
command = optional(list(string))
145+
env = optional(list(object({
146+
name = string
147+
secretRef = optional(string)
148+
value = optional(string)
149+
})))
150+
image = string
151+
name = string
152+
probes = optional(list(object({
153+
failureThreshold = optional(number)
154+
httpGet = optional(object({
155+
host = optional(string)
156+
httpHeaders = optional(list(object({
157+
name = string
158+
value = string
159+
})))
160+
path = optional(string)
161+
port = optional(number)
162+
scheme = optional(string)
163+
}))
164+
initialDelaySeconds = optional(number)
165+
periodSeconds = optional(number)
166+
successThreshold = optional(number)
167+
tcpSocket = optional(object({
168+
host = optional(string)
169+
port = optional(number)
170+
}))
171+
terminationGracePeriodSeconds = optional(number)
172+
timeoutSeconds = optional(number)
173+
type = optional(string)
174+
})))
175+
resources = optional(object({
176+
cpu = optional(string)
177+
memory = optional(string)
178+
}))
179+
volumeMounts = optional(list(object({
180+
mountPath = optional(string)
181+
subPath = optional(string)
182+
volumeName = optional(string)
183+
})))
184+
}))
185+
initContainers = optional(list(object({
186+
args = optional(list(string))
187+
command = optional(list(string))
188+
env = optional(list(object({
189+
name = string
190+
secretRef = optional(string)
191+
value = optional(string)
192+
})))
193+
image = string
194+
name = string
195+
resources = optional(object({
196+
cpu = optional(string)
197+
memory = optional(string)
198+
}))
199+
volumeMounts = optional(list(object({
200+
mountPath = optional(string)
201+
subPath = optional(string)
202+
volumeName = optional(string)
203+
})))
204+
})))
205+
revisionSuffix = optional(string, null)
206+
scale = optional(object({
207+
maxReplicas = optional(number)
208+
minReplicas = optional(number)
209+
rules = optional(list(object({
210+
azureQueue = optional(object({
211+
auth = optional(list(object({
212+
secretRef = string
213+
triggerParameter = string
214+
})))
215+
queueLength = optional(number)
216+
queueName = optional(string)
217+
}))
218+
custom = optional(object({
219+
auth = optional(list(object({
220+
secretRef = string
221+
triggerParameter = string
222+
})))
223+
metadata = optional(map(string))
224+
type = optional(string)
225+
}))
226+
http = optional(object({
227+
auth = optional(list(object({
228+
secretRef = string
229+
triggerParameter = string
230+
})))
231+
metadata = optional(map(string))
232+
}))
233+
name = optional(string)
234+
tcp = optional(object({
235+
auth = optional(list(object({
236+
secretRef = string
237+
triggerParameter = string
238+
})))
239+
metadata = optional(map(string))
240+
}))
241+
})))
242+
}))
243+
serviceBinds = optional(list(object({
244+
name = string
245+
serviceId = string
246+
})))
247+
volumes = optional(list(object({
248+
mountOptions = string
249+
name = string
250+
secrets = optional(list(object({
251+
path = string
252+
secretRef = string
253+
})))
254+
storageName = string
255+
storageType = string
256+
})))
257+
})
258+
}))
259+
```
260+
261+
### <a name="input_name"></a> [name](#input\_name)
262+
263+
Description: Name for the resource.
264+
265+
Type: `string`
266+
49267
### <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name)
50268

51269
Description: The resource group where the resources will be deployed.
@@ -64,11 +282,47 @@ If it is set to false, then no telemetry will be collected.
64282

65283
Type: `bool`
66284

67-
Default: `true`
285+
Default: `false`
286+
287+
### <a name="input_location"></a> [location](#input\_location)
288+
289+
Description: Azure region where the resource should be deployed.
290+
291+
Type: `string`
292+
293+
Default: `null`
294+
295+
### <a name="input_tags"></a> [tags](#input\_tags)
296+
297+
Description: Custom tags to apply to the resource.
298+
299+
Type: `map(string)`
300+
301+
Default: `{}`
302+
303+
### <a name="input_user_identity_resource_id"></a> [user\_identity\_resource\_id](#input\_user\_identity\_resource\_id)
304+
305+
Description: The managed identity definition for this resource.
306+
307+
Type: `string`
308+
309+
Default: `""`
310+
311+
### <a name="input_workload_profile_name"></a> [workload\_profile\_name](#input\_workload\_profile\_name)
312+
313+
Description: Workload profile name to pin for container app execution. If not set, workload profiles are not used.
314+
315+
Type: `string`
316+
317+
Default: `null`
68318

69319
## Outputs
70320

71-
No outputs.
321+
The following outputs are exported:
322+
323+
### <a name="output_resource"></a> [resource](#output\_resource)
324+
325+
Description: The Container Apps resource.
72326

73327
## Modules
74328

0 commit comments

Comments
 (0)