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

New Resource - azurerm_linux_function_app_flex_consumption #28199

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

xiaxyi
Copy link
Contributor

@xiaxyi xiaxyi commented Dec 6, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

To make a separate pr for this new feature, referring to the #27531

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_resource - support for the thing1 property [GH-00000]

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #0000

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@nzthiago
Copy link

nzthiago commented Dec 6, 2024

@xiaxyi - thank you for this PR. Only note from me is we don't want customers to worry about operating system, with no plans for a Windows version of Flex Consumption in the foreseeable future. Can we please simplify the name and code not to have Linux in it for Flex Consumption? Other than that I'm happy with separating it out into its own resource type, thank you.

@xiaxyi
Copy link
Contributor Author

xiaxyi commented Dec 10, 2024

Thanks @nzthiago for the suggestions, @jackofallops are you agree with the idea of removing the linux part?

@nzthiago
Copy link

Following up on this one @jackofallops - from the Azure Functions PG we would prefer to drop 'linux' from the resource name.

@pcsrijith
Copy link

@jackofallops : Could you please update on @nzthiago 's suggestions? We are eagerly waiting for this actually.

@NipunaPrashan
Copy link

Happy New Year @jackofallops. Could you be able to check on the suggestions?

@stephybun
Copy link
Member

@xiaxyi please go ahead and remove linux from the resource name

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

@xiaxyi, as a heads up this will require a few rounds of reviews, but I've made a first pass through to call out some consistency and style choices. Could you fix those up? I can then go over this in detail with our App Service SME.

Thanks!

AppCommandLine string `tfschema:"app_command_line"`
ApiDefinition string `tfschema:"api_definition_url"`
ApiManagementConfigId string `tfschema:"api_management_api_id"`
AppInsightsInstrumentationKey string `tfschema:"application_insights_key"` // App Insights Instrumentation Key
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this comment here since it isn't really alluding to anything helpful (the name is already descriptive)

Suggested change
AppInsightsInstrumentationKey string `tfschema:"application_insights_key"` // App Insights Instrumentation Key
AppInsightsInstrumentationKey string `tfschema:"application_insights_key"`

Http2Enabled bool `tfschema:"http2_enabled"`
IpRestriction []IpRestriction `tfschema:"ip_restriction"`
IpRestrictionDefaultAction string `tfschema:"ip_restriction_default_action"`
LoadBalancing string `tfschema:"load_balancing_mode"` // TODO - Valid for FunctionApps?
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment relevant here?

Suggested change
LoadBalancing string `tfschema:"load_balancing_mode"` // TODO - Valid for FunctionApps?
LoadBalancing string `tfschema:"load_balancing_mode"`

RuntimeScaleMonitoring bool `tfschema:"runtime_scale_monitoring_enabled"`
ScmIpRestriction []IpRestriction `tfschema:"scm_ip_restriction"`
ScmIpRestrictionDefaultAction string `tfschema:"scm_ip_restriction_default_action"`
ScmType string `tfschema:"scm_type"` // Computed?
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Suggested change
ScmType string `tfschema:"scm_type"` // Computed?
ScmType string `tfschema:"scm_type"`

Optional: true,
Description: "The path to be checked for this function app health.",
RequiredWith: func() []string {
if features.FourPointOhBeta() {
Copy link
Member

Choose a reason for hiding this comment

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

4.0 has been shipped so we shouldn't be using this flag anywhere anymore

Computed: !features.FourPointOhBeta(),
ValidateFunc: validation.IntBetween(2, 10),
RequiredWith: func() []string {
if features.FourPointOhBeta() {
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Comment on lines 786 to 788
if existing.Model == nil || existing.Model.Properties == nil {
return fmt.Errorf("reading of Linux %s for update", id)
}
Copy link
Member

Choose a reason for hiding this comment

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

For consistency these checks should be split and return the following error messages

Suggested change
if existing.Model == nil || existing.Model.Properties == nil {
return fmt.Errorf("reading of Linux %s for update", id)
}
if existing.Model == nil {
return fmt.Errorf("reading %s: `model` was nil", id)
}
existing.Model.Properties == nil {
return fmt.Errorf("reading %s: `properties` was nil", id)
}

Comment on lines 339 to 342
if response.WasNotFound(resp.HttpResponse) {
return pointer.To(false), nil
}
return nil, fmt.Errorf("retrieving Linux Function App %s: %+v", id, err)
Copy link
Member

Choose a reason for hiding this comment

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

We don't check for 404 in the exists check for the tests, any error when we try to get the resource in this check should be returned

Suggested change
if response.WasNotFound(resp.HttpResponse) {
return pointer.To(false), nil
}
return nil, fmt.Errorf("retrieving Linux Function App %s: %+v", id, err)
return nil, fmt.Errorf("retrieving %s: %+v", id, err)

Comment on lines 344 to 346
if response.WasNotFound(resp.HttpResponse) {
return pointer.To(false), nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if response.WasNotFound(resp.HttpResponse) {
return pointer.To(false), nil
}

if response.WasNotFound(resp.HttpResponse) {
return pointer.To(false), nil
}
return pointer.To(true), nil
Copy link
Member

Choose a reason for hiding this comment

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

The existence of a Model in the response confirms whether the resource exists or not

Suggested change
return pointer.To(true), nil
return pointer.To(resp.Model != nil), nil

%s
resource "azurerm_linux_function_app_flex_consumption" "test" {
name = "xiaxintest-LFA-tf%d"
Copy link
Member

Choose a reason for hiding this comment

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

Resource names in the acceptance tests should begin with acc

@xiaxyi
Copy link
Contributor Author

xiaxyi commented Jan 9, 2025

@stephybun Thanks for the review, I understand it will take server rounds of review, that's totally fine.

I updated the pr based on the comments, feel free to let me know if anything needed.

@pcsrijith
Copy link

@stephybun Thanks for the review, I understand it will take server rounds of review, that's totally fine.

I updated the pr based on the comments, feel free to let me know if anything needed.

I believe, linux word needs to be removed from filenames, MR title and in codes as well.

@nzthiago
Copy link

@stephybun I believe this is ready for the next round of review, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants