From e233dbe033a58d07dae260f68965bf8dabf897d8 Mon Sep 17 00:00:00 2001 From: Anders Eide Date: Mon, 2 Dec 2024 08:31:18 -0600 Subject: [PATCH] fix: Fixes issue in `avm/res/container-instance/container-group` when container memory is set to less than 1 GB. (#3752) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description * Changed `memoryInGB` prop in type `containerType` from `int` to `string` * Updated tests to use `string` instead of `int` * Added test that uses memoryInGB value less than 1 * Updated documentation to no longer recommend using `json('0.5')` when using value less than 1 Closes #3655 ## Pipeline Reference | Pipeline | | -------- | | [![avm.res.container-instance.container-group](https://github.com/anderseide/avm-bicep-registry-modules/actions/workflows/avm.res.container-instance.container-group.yml/badge.svg?branch=container-instance-memory)](https://github.com/anderseide/avm-bicep-registry-modules/actions/workflows/avm.res.container-instance.container-group.yml) | ## Type of Change - [ ] Update to CI Environment or utilities (Non-module affecting changes) - [X] Azure Verified Module updates: - [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [X] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [X] Breaking changes and I have bumped the MINOR version in `version.json`. - [X] Update to documentation ## Checklist - [X] I'm sure there are no other open Pull Requests for the same update/change - [X] I have run `Set-AVMModule` locally to generate the supporting module files. - [X] My corresponding pipelines / checks run clean and green without any errors or warnings --------- Co-authored-by: Julian Peißker <30857628+JPEasier@users.noreply.github.com> Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com> Co-authored-by: Kris Baranek <20225789+krbar@users.noreply.github.com> Co-authored-by: Alexander Sehr --- .../container-group/README.md | 237 +++++++++++++++--- .../container-group/main.bicep | 8 +- .../container-group/main.json | 10 +- .../tests/e2e/defaults/main.test.bicep | 2 +- .../tests/e2e/encr/main.test.bicep | 4 +- .../tests/e2e/low-memory/main.test.bicep | 74 ++++++ .../tests/e2e/max/main.test.bicep | 8 +- .../tests/e2e/private/main.test.bicep | 4 +- .../tests/e2e/waf-aligned/main.test.bicep | 4 +- .../container-group/version.json | 2 +- 10 files changed, 295 insertions(+), 58 deletions(-) create mode 100644 avm/res/container-instance/container-group/tests/e2e/low-memory/main.test.bicep diff --git a/avm/res/container-instance/container-group/README.md b/avm/res/container-instance/container-group/README.md index 1545fb232b..53c1daf65d 100644 --- a/avm/res/container-instance/container-group/README.md +++ b/avm/res/container-instance/container-group/README.md @@ -28,9 +28,10 @@ The following section provides usage examples for the module, which were used to - [Using only defaults](#example-1-using-only-defaults) - [Using CMK ](#example-2-using-cmk) -- [Using large parameter set](#example-3-using-large-parameter-set) -- [Using private network](#example-4-using-private-network) -- [WAF-aligned](#example-5-waf-aligned) +- [Using only defaults and low memory containers](#example-3-using-only-defaults-and-low-memory-containers) +- [Using large parameter set](#example-4-using-large-parameter-set) +- [Using private network](#example-5-using-private-network) +- [WAF-aligned](#example-6-waf-aligned) ### Example 1: _Using only defaults_ @@ -60,7 +61,7 @@ module containerGroup 'br/public:avm/res/container-instance/container-group:

-### Example 3: _Using large parameter set_ +### Example 3: _Using only defaults and low memory containers_ + +This instance deploys the module with the minimum set of required parameters and with low memory. + + +

+ +via Bicep module + +```bicep +module containerGroup 'br/public:avm/res/container-instance/container-group:' = { + name: 'containerGroupDeployment' + params: { + // Required parameters + containers: [ + { + name: 'az-aci-x-001' + properties: { + image: 'mcr.microsoft.com/azuredocs/aci-helloworld' + ports: [ + { + port: 443 + protocol: 'Tcp' + } + ] + resources: { + requests: { + cpu: 2 + memoryInGB: '0.5' + } + } + } + } + ] + name: 'ciclow001' + // Non-required parameters + ipAddressPorts: [ + { + port: 443 + protocol: 'Tcp' + } + ] + location: '' + } +} +``` + +
+

+ +

+ +via JSON parameters file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + // Required parameters + "containers": { + "value": [ + { + "name": "az-aci-x-001", + "properties": { + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ + { + "port": 443, + "protocol": "Tcp" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": "0.5" + } + } + } + } + ] + }, + "name": { + "value": "ciclow001" + }, + // Non-required parameters + "ipAddressPorts": { + "value": [ + { + "port": 443, + "protocol": "Tcp" + } + ] + }, + "location": { + "value": "" + } + } +} +``` + +
+

+ +

+ +via Bicep parameters file + +```bicep-params +using 'br/public:avm/res/container-instance/container-group:' + +// Required parameters +param containers = [ + { + name: 'az-aci-x-001' + properties: { + image: 'mcr.microsoft.com/azuredocs/aci-helloworld' + ports: [ + { + port: 443 + protocol: 'Tcp' + } + ] + resources: { + requests: { + cpu: 2 + memoryInGB: '0.5' + } + } + } + } +] +param name = 'ciclow001' +// Non-required parameters +param ipAddressPorts = [ + { + port: 443 + protocol: 'Tcp' + } +] +param location = '' +``` + +
+

+ +### Example 4: _Using large parameter set_ This instance deploys the module with most of its features enabled. @@ -506,9 +653,13 @@ module containerGroup 'br/public:avm/res/container-instance/container-group:

-### Example 4: _Using private network_ +### Example 5: _Using private network_ This instance deploys the module within a virtual network. @@ -813,7 +972,7 @@ module containerGroup 'br/public:avm/res/container-instance/container-group:

-### Example 5: _WAF-aligned_ +### Example 6: _WAF-aligned_ This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework. @@ -1085,7 +1244,7 @@ module containerGroup 'br/public:avm/res/container-instance/container-group: