Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: api-management.service new v0.2 #2453

Merged
merged 66 commits into from
Jun 19, 2024
Merged

feat: api-management.service new v0.2 #2453

merged 66 commits into from
Jun 19, 2024

Conversation

tony-box
Copy link
Contributor

@tony-box tony-box commented Jun 15, 2024

Description

Closes #2075
Closes #1929
Closes #1124
Closes #1104
Closes #2362
Closes #2444
Fixes #2361
Closes #1473

Big update v0.2 release:

  • update all APIM apis to newer versions
  • new feat: Add PublicIP
  • new feat: add API Loggers
  • new feat: add API Diagnostics
  • new feat: add v2sku options
  • add test case for v2sku
  • updates to many default params to better align with PSRule suggestions for better reliability and security (big one is multi region and AZ deployment)

Pipeline Reference

Pipeline
avm.res.api-management.service

Type of Change

  • Update to CI Environment or utilities (Non-module affecting changes)
  • Azure Verified Module updates:
    • Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in version.json:
      • 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.
    • Breaking changes and I have bumped the MAJOR version in version.json.
    • Update to documentation

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • I have run Set-AVMModule locally to generate the supporting module files.
  • My corresponding pipelines / checks run clean and green without any errors or warnings

@tony-box tony-box requested a review from a team as a code owner June 15, 2024 21:45
@tony-box tony-box enabled auto-merge (squash) June 15, 2024 21:45
@tony-box
Copy link
Contributor Author

@Azure/avm-core-team-technical-bicep sorry for the large PR but I thought it was the best way to get everything submitted in a timely manner. I promise I won't make this a habit... just trying to get a bunch of these open bugs resolved.

@matebarabas matebarabas added Class: Resource Module 📦 This is a resource module Needs: Core Team 🧞 This item needs the AVM Core Team to review it and removed Needs: Triage 🔍 Maintainers need to triage still labels Jun 19, 2024
Copy link
Contributor

@jtracey93 jtracey93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :rocket

@tony-box tony-box merged commit 8a869fa into Azure:main Jun 19, 2024
11 checks passed
@tony-box tony-box deleted the v0.2 branch June 19, 2024 17:39
hundredacres pushed a commit to hundredacres/bicep-registry-modules that referenced this pull request Jun 19, 2024
## Description

<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.

Fixes Azure#123
Fixes Azure#456
Closes Azure#123
Closes Azure#456
-->

Closes Azure#2075 
Closes Azure#1929 
Closes Azure#1124 
Closes Azure#1104 
Closes Azure#2362 
Closes Azure#2444 

Big update v0.2 release:

- update all APIM apis to newer versions
- new feat: Add PublicIP
- new feat: add API Loggers
- new feat: add API Diagnostics
- new feat: add v2sku options
- add test case for v2sku
- updates to many default params to better align with PSRule suggestions
for better reliability and security

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.api-management.service](https://github.com/tony-box/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml/badge.svg?branch=v0.2)](https://github.com/tony-box/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [x] 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.
- [x] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR 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

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Tony Box <[email protected]>
@@ -81,3 +81,4 @@ rule:
- Azure.VM.UseHybridUseBenefit
- Azure.Storage.UseReplication
- Azure.AppConfig.PurgeProtect
- Azure.APIM.MultiRegion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was ther reson for this? We should probably start attaching comments with the reason to every suppression

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we agreed in Teams to disable this one. It's untenable for most deployments to use multiregion deployment for APIM in every case ($$$), despite it being recommended.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Tony, the reason is absolutely fine. If possible please add it as a comment at the end of the line. Something we should really start doing for later reference 🙂

}

resource diagnostic 'Microsoft.ApiManagement/service/apis/diagnostics@2022-08-01' = {
name: diagnosticName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be called diagnosticName but name as per spec Inputs - Parameter/Variable Naming

resource api 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
name: name
resource api 'Microsoft.ApiManagement/service/apis@2022-08-01' = {
name: apiName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be name as per spec Inputs - Parameter/Variable Naming

@description('Required. Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API.')
param path string
param apiPath string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be api as per spec Inputs - Parameter/Variable Naming

Background: As it's the path parameter of the api resource type it should be intuitive that it's the api's path. Following this logic it would be redundant to call it apiPath

for (diagnostic, index) in diagnostics ?? []: {
name: '${deployment().name}-diagnostics-${index}'
params: {
diagnosticName: !empty(diagnostic.diagnosticName) ? diagnostic.diagnosticName : '${api.name}-diagnostics-${index}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does have a different default than in the child?

There the diagnosticName parameter's default is 'local'. It's very different and it may have been better to use '${apiName}-diagnostics' in the child

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, just to suggest an improvement to simplify the code, you could write diagnosticName: diagnostic.?diagnosticName ?? '${api.name}-diagnostics-${index}'

param targetResourceId string

@description('Conditional. Required if loggerType = applicationInsights or azureEventHub. The name and SendRule connection string of the event hub for azureEventHub logger. Instrumentation key for applicationInsights logger.')
param credentials object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not maybe have the annotation @secure() or are there no secrets in this object?

@@ -54,7 +63,7 @@ param restore bool = false
@description('Optional. Array of role assignments to create.')
param roleAssignments roleAssignmentType

@description('Optional. The pricing tier of this API Management service.')
@description('Optional. The pricing tier of this API Management service. Default is Premium.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is representative of all parameters - the default should not be part of the name because

  • in the readme.md it's automatically added from the default
  • in Bicep linter (when using the module) it's automatically suggested
  • It adds another location (per parameter) where you'd need to maintain the value - so it could run stale
Suggested change
@description('Optional. The pricing tier of this API Management service. Default is Premium.')
@description('Optional. The pricing tier of this API Management service.')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be the same comment across all modules, btw :) I'll refrain from commenting every instance though

}

resource diagnostic 'Microsoft.ApiManagement/service/apis/diagnostics@2022-08-01' = {
name: diagnosticName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as per the product api - should not contain the resource type's name as per Inputs - Parameter/Variable Naming

Comment on lines +184 to +189
managedIdentities: {
systemAssigned: true
userAssignedResourceIds: [
nestedDependencies.outputs.managedIdentityResourceId
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for WAF alignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, required for Azure.APIM.ManagedIdentity

@v-xuto
Copy link
Member

v-xuto commented Jun 21, 2024

@tony-box The changes related to this PR seem to have not been published successfully, please confirm.

@AlexanderSehr
Copy link
Contributor

AlexanderSehr commented Jun 21, 2024

Hey @v-xuto that's correct. One of the tests failed due to an internal server error. We'll merge a new PR asap - including the suggested changes above. @tony-box started working on it right away

@tony-box tony-box mentioned this pull request Jun 23, 2024
11 tasks
tony-box added a commit that referenced this pull request Jun 23, 2024
## Description

<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.

Fixes #123
Fixes #456
Closes #123
Closes #456
-->

Fixes issues from the previous PR: #2453 

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.api-management.service](https://github.com/tony-box/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml/badge.svg?branch=fix%2Fapim)](https://github.com/tony-box/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [X] Update to CI Environment or utilities (Non-module affecting
changes)
- [X] Azure Verified Module updates:
- [X] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [X] 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`.
- [ ] Breaking changes and I have bumped the MAJOR 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

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Tony Box <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment