Skip to content

New resource: azurerm_managed_lustre_file_system_auto_export_job#29908

Open
jiaweitao001 wants to merge 20 commits intohashicorp:mainfrom
jiaweitao001:storage_cache_autoexport
Open

New resource: azurerm_managed_lustre_file_system_auto_export_job#29908
jiaweitao001 wants to merge 20 commits intohashicorp:mainfrom
jiaweitao001:storage_cache_autoexport

Conversation

@jiaweitao001
Copy link
Copy Markdown
Collaborator

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

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 relevant 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

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the provider.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Note

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

Copy link
Copy Markdown
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

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

@jiaweitao001, this is looking good so far, just a few comments I have left which I think should be addressed. Outside of those this LGTM! 🚀

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we have a more robust validation for the name here? The documentation mentions the following requierments for the name field:

  • minLength: 2
  • maxLength: 80
  • pattern: ^[0-9a-zA-Z][-0-9a-zA-Z_]{0,78}[0-9a-zA-Z]$

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, will fix.

Comment on lines +66 to +73
"auto_export_prefixes": {
Type: pluginsdk.TypeList,
Required: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Number of maximum allowed paths for now is 1, so we should enforce that in the schema. Since this is an array of blob paths/prefixes which defaults to / can we also add a better validation function here as well?

Suggested change
"auto_export_prefixes": {
Type: pluginsdk.TypeList,
Required: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
},
"auto_export_prefixes": {
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will change.

type ManagedLustreFileSystemAutoExportJobResource struct{}

func (r ManagedLustreFileSystemAutoExportJobResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := autoexportjobs.ParseAutoExportJobID(state.ID)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we add some more tests here, at least a requiresImport and an update?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will do.

* `auto_export_prefixes` - (Required) A list of prefixes that get auto exported to the cluster namespace.

* `admin_status` - (Optional) The administrative status of the Auto Export Job. Possible values are `Enable` and `Disable`. Defaults to `Enable`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we need to also add the Attributes Reference here as well, WDYT?

Suggested change
## Attributes Reference
In addition to the arguments listed above - the following attributes are exported:
* `id` - The Azure Managed Lustre File System Auto Export Job ID.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure. Will add .

Copy link
Copy Markdown
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks @jiaweitao001, it looks like there are test failures on this in tc, could you take a look please?

------- Stdout: -------
=== RUN   TestAccManagedLustreFileSystemExportJob_requiresImport
=== PAUSE TestAccManagedLustreFileSystemExportJob_requiresImport
=== CONT  TestAccManagedLustreFileSystemExportJob_requiresImport
    testcase.go:173: Step 1/2 error: Error running apply: exit status 1
        Error: creating Aml Filesystem (Subscription: "*******"
        Resource Group Name: "acctestRG-amlfs-250724040016680629"
        Aml Filesystem Name: "acctest-amlfs-250724040016680629"): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: BadRequest: Storage Account acctestsa0bdzx is not found or is inaccessible.
          with azurerm_managed_lustre_file_system.test,
          on terraform_plugin_test.tf line 147, in resource "azurerm_managed_lustre_file_system" "test":
         147: resource "azurerm_managed_lustre_file_system" "test" {
        creating Aml Filesystem (Subscription: "*******"
        Resource Group Name: "acctestRG-amlfs-250724040016680629"
        Aml Filesystem Name: "acctest-amlfs-250724040016680629"): performing
        CreateOrUpdate: unexpected status 400 (400 Bad Request) with error:
        BadRequest: Storage Account acctestsa0bdzx is not found or is inaccessible.
--- FAIL: TestAccManagedLustreFileSystemExportJob_requiresImport (264.50s)
FAIL

@github-actions
Copy link
Copy Markdown
Contributor

This PR is being labeled as "stale" because it has not been updated for 30 or more days.

If this PR is still valid, please remove the "stale" label. If this PR is blocked, please add it to the "Blocked" milestone.

If you need some help completing this PR, please leave a comment letting us know. Thank you!

@github-actions github-actions bot added the stale label Nov 10, 2025
Copy link
Copy Markdown
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

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

Thanks @jiaweitao001, I've left some comments inline

Comment on lines +58 to +65
"resource_group_name": commonschema.ResourceGroupName(),

"aml_file_system_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.ManagedLustreFileSystemName,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When there are multiple properties required to create the parent resource's ID, we generally expose it as a single resource ID property, e.g.

"managed_lustre_file_system_id": commonschema.ResourceIDReferenceRequiredForceNew(&amlfilesystems.AmlFilesystemId{}),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure. Will address this.

"auto_export_prefixes": {
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is MaxItems: 1 correct here? If users can only specify one prefix this should probably be auto_export_prefix and TypeString.

Unless this is meant to be MinItems: 1?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right, this should be MinItems. Will fix.


existing, err := autoExportJobsClient.Get(ctx, id)
if err != nil && !response.WasNotFound(existing.HttpResponse) {
return fmt.Errorf("checking for existing Auto Export Job %s: %+v", id, err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("checking for existing Auto Export Job %s: %+v", id, err)
return fmt.Errorf("checking for existing %s: %+v", id, err)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.

Comment on lines +165 to +169
if props.AdminStatus != nil && string(pointer.From(props.AdminStatus)) == string(autoexportjob.AutoExportJobAdminStatusEnable) {
state.AdminStatusEnabled = true
} else {
state.AdminStatusEnabled = false
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We could simplify this to:

Suggested change
if props.AdminStatus != nil && string(pointer.From(props.AdminStatus)) == string(autoexportjob.AutoExportJobAdminStatusEnable) {
state.AdminStatusEnabled = true
} else {
state.AdminStatusEnabled = false
}
state.AdminStatusEnabled = pointer.From(props.AdminStatus) == autoexportjobs.AutoExportJobAdminStatusEnable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.

Comment on lines +28 to +30
if response.WasNotFound(resp.HttpResponse) {
return pointer.To(false), nil
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we generally just return any error encounter in the Exists func

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will remove.

location = azurerm_resource_group.test.location

auto_export_prefixes = ["/"]
admin_status_enabled = true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this defaults to true, could you change it to false for the complete test to ensure we can update this property?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will do.

aml_file_system_name = azurerm_managed_lustre_file_system.test.name
location = azurerm_resource_group.test.location

auto_export_prefixes = ["/"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you update this value so it's different from the value specified in the basic test?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure.

location = azurerm_managed_lustre_file_system_auto_export_job.test.location

auto_export_prefixes = azurerm_managed_lustre_file_system_auto_export_job.test.auto_export_prefixes
admin_status_enabled = azurerm_managed_lustre_file_system_auto_export_job.test.admin_status_enabled
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

import config should match referenced config (r.basic)

Suggested change
admin_status_enabled = azurerm_managed_lustre_file_system_auto_export_job.test.admin_status_enabled

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.


* `auto_export_prefixes` - (Required) A list of prefixes that get auto exported to the cluster namespace.

* `admin_status_enabled` - (Optional) Whether the administrative status of the Auto Export Job is enabled. Possible values are `true` and `false`. Defaults to `true`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For booleans we don't need to include the possible values

Suggested change
* `admin_status_enabled` - (Optional) Whether the administrative status of the Auto Export Job is enabled. Possible values are `true` and `false`. Defaults to `true`.
* `admin_status_enabled` - (Optional) Whether the administrative status of the Auto Export Job is enabled. Defaults to `true`.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.


## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We've recently updated the timeout reference url, would you mind changing this to

Suggested change
The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will change.

Copy link
Copy Markdown
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

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

Hi @jiaweitao001, it looks like there are some test failures. A couple are due to a separate issue relating to the resource group resource, however there is one that will need to be addressed. Based on the error, it seems auto_export_prefixes may need to be ForceNew:

Error: updating Auto Export Job (Subscription: "*******"
        Resource Group Name: "acctestRG-amlfs-251126213709780808"
        Aml Filesystem Name: "acctest-amlfs-251126213709780808"
        Auto Export Job Name: "acctest-amlfsaej-251126213709780808"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: PropertyChangeNotAllowed: Changing property 'autoExportJob.properties.autoExportPrefixes' is not allowed.
          with azurerm_managed_lustre_file_system_auto_export_job.test,
          on terraform_plugin_test.tf line 195, in resource "azurerm_managed_lustre_file_system_auto_export_job" "test":
         195: resource "azurerm_managed_lustre_file_system_auto_export_job" "test" {

@jiaweitao001
Copy link
Copy Markdown
Collaborator Author

Hi @jiaweitao001, it looks like there are some test failures. A couple are due to a separate issue relating to the resource group resource, however there is one that will need to be addressed. Based on the error, it seems auto_export_prefixes may need to be ForceNew:

Error: updating Auto Export Job (Subscription: "*******"
        Resource Group Name: "acctestRG-amlfs-251126213709780808"
        Aml Filesystem Name: "acctest-amlfs-251126213709780808"
        Auto Export Job Name: "acctest-amlfsaej-251126213709780808"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: PropertyChangeNotAllowed: Changing property 'autoExportJob.properties.autoExportPrefixes' is not allowed.
          with azurerm_managed_lustre_file_system_auto_export_job.test,
          on terraform_plugin_test.tf line 195, in resource "azurerm_managed_lustre_file_system_auto_export_job" "test":
         195: resource "azurerm_managed_lustre_file_system_auto_export_job" "test" {

Right. The provided description neglected this. Will fix.

@jiaweitao001 jiaweitao001 force-pushed the storage_cache_autoexport branch from 6d8c40f to 0fc76ed Compare March 18, 2026 07:32
jiaweitao001 and others added 2 commits March 25, 2026 16:03
The Create function performs three sequential long-running operations
(waitForImportJobs, CreateOrUpdateThenPoll, UpdateThenPoll) that can
cumulatively exceed the previous 60-minute timeout, causing context
deadline exceeded errors when disabling admin status.

Increase both Create and Update timeouts from 60 to 120 minutes and
update documentation accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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