Terraform: What pairs with "Supported_Restrictions" key?

Good afternoon!

I’m working on a Terraform script, specifically on user roles using this page: https://registry.terraform.io/providers/OctopusDeployLabs/octopusdeploy/latest/docs/resources/user_role

I have copied the entire ‘Example’ block and tried to deploy, yielding error:

│ Error: Octopus API error: Value cannot be null.
│ Parameter name: source [] Value cannot be null.
│ Parameter name: source
│ System.ArgumentNullException
│ at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable1 source, Func2 selector)
│ at Octopus.Server.Web.Api.Rules.EditAndCreateForceViewPermissionRule.g__GetViewPermssionsMatchingSuffix2_0(String suffix, String replaceWith, <>c__DisplayClass2_0& )
│ at Octopus.Server.Web.Api.Rules.EditAndCreateForceViewPermissionRule.BeforeMap(UserRole model, UserRoleResource resource, ISpecialRuleContext context)
│ at Octopus.Server.Web.Infrastructure.Api.Responder1.ExecuteRegisteredRules[TRule](Action2 ruleCallback)
│ at Octopus.Server.Web.Infrastructure.Api.CreateResponseDescriptor2.Responder.ExecuteRegistered() │ at Octopus.Server.Web.Infrastructure.Api.Responder1.Respond(TDescriptor options, NancyContext context)
│ at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
│ at Octopus.Server.Web.Infrastructure.OctopusNancyModule.<>c__DisplayClass14_0.<get_Routes>b__1(Object x)
│ at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)

│ with octopusdeploy_user_role.DCODreleasemanagers,
│ on CUSTmain.tf line 33, in resource “octopusdeploy_user_role” “DCODreleasemanagers”:
│ 33: resource “octopusdeploy_user_role” “DCODreleasemanagers” {

The only key I don’t have included is the ‘supported_restrictions’ key. I’ve added this with a ‘none’ value, but the script pukes on such. Notably, I don’t get the ‘Value cannot be null’ with ‘supported_restrictions’ inserted.

SO, what values pair up with ‘suggested_restrictions’, so that I may work my way out of this hole? So close to being done!

-Thank you

Hey Sedge,

Thanks for reaching out on our community forum!

Would you be able to send me the full Terraform script you are using? You can send it via direct message or use the follow secure upload link if you’d prefer. That script should help us do some testing our end and to ensure we point you down the right path.
Secure Upload

Thanks,
Brent

Good morning,

I’ve uploaded the files - super basic script to test functionality before diving deeper. I should also mention that this is pointing way back to v3.17.14 as currently required by my dev team. :expressionless:

Thank you for having a look,

Hi Sedge,

Thanks for sending those files over. I was able to do some local testing and was able to get the variable substitution working. Can you move the variable definitions from your variables.tf file to the CUSTmain.tf file instead? That should prevent the ‘Error: Octopus API error: Value cannot be null.’ error you have been getting.

Once the variable definitions are added to the CUSTmain.tf, you should be able to run your Terraform script and set your original terraform.tfvars file in the command line using a command like this:
terraform apply -var-file=“c:\pathtofile\terraform.tfvars”

Let me know how you progress and if you run into any other errors.

Thanks,
Brent

Hello!

I fully reinstalled the Octopus environment to run this fresh, after moving all variables.tf definitions to CUSTmain.tf. Applied the deployment with suggested command, but the ‘Octopus API error: Value cannot be null.’ remains.

│ Error: Octopus API error: Value cannot be null.
│ Parameter name: source [] Value cannot be null.
│ Parameter name: source
│ System.ArgumentNullException
│ at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable1 source, Func2 selector)
│ at Octopus.Server.Web.Api.Rules.EditAndCreateForceViewPermissionRule.g__GetViewPermssionsMatchingSuffix2_0(String suffix, String replaceWith, <>c__DisplayClass2_0& )
│ at Octopus.Server.Web.Api.Rules.EditAndCreateForceViewPermissionRule.BeforeMap(UserRole model, UserRoleResource resource, ISpecialRuleContext context)
│ at Octopus.Server.Web.Infrastructure.Api.Responder1.ExecuteRegisteredRules[TRule](Action2 ruleCallback)
│ at Octopus.Server.Web.Infrastructure.Api.CreateResponseDescriptor2.Responder.ExecuteRegistered() │ at Octopus.Server.Web.Infrastructure.Api.Responder1.Respond(TDescriptor options, NancyContext context)
│ at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
│ at Octopus.Server.Web.Infrastructure.OctopusNancyModule.<>c__DisplayClass14_0.<get_Routes>b__1(Object x)
│ at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)

│ with octopusdeploy_user_role.DCODreleasemanagers,
│ on CUSTmain.tf line 54, in resource “octopusdeploy_user_role” “DCODreleasemanagers”:
│ 54: resource “octopusdeploy_user_role” “DCODreleasemanagers” {

New .zip has been uploaded to reflect these changes.

-S

Hi Sedge,

Apologies, I should have caught this in your initial inquiry, but the version of Octopus you are running does not support Terraform. This blog post goes over getting started with Terraform, which requires Octopus Deploy 2019.1 or newer.

If there is anything else you need or if other questions come up, don’t hesitate to reach out again here or by sending an email to support@octopus.com

Again, I am sorry I did not catch that sooner.

Thanks,
Brent

Thanks for taking a look at this anyways! I completely understand.

For original inquiry reference and future knowledge - what strings were associated with the supported_restrictions key?

Thank you,

I am not a Terraform expert, but I don’t believe the script even got to that tag. The error occurred when your API Key connected to your server instance and failed as it couldn’t handle the Terraform request.

Since the Terraform documentation lists that parameter as optional, in the future, I would leave that tag off your script rather than listing it and providing a value of ‘none.’

I hope this helps; let me know if you have more questions.

Thanks,