https://pulumi.com logo
#typescript
Title
# typescript
q

quiet-hairdresser-18834

01/27/2021, 5:24 PM
I am struggling with inputs / outputs or just my general understanding
Copy code
let agwConfig: azure.network.ApplicationGatewayArgs = {
        name: agwName,
        resourceGroupName: resourceGroup.name,
        autoscaleConfiguration: {
                    minCapacity: appGatewayAutoScaleMinimumInstanceCount,
                    maxCapacity: appGatewayAutoScaleMaximumInstanceCount 
        }
        //... more code here
   }
If I wanted to optionally have the autoscaleConfiguration not be set to anything, how can I do that? I tried clearing it after with
Copy code
if (!useAppGateayAutoScale)
    {
        agwConfig.autoscaleConfiguration = null;
    }
but it gives me an error that the property is readonly so it can not be changed
w

witty-candle-66007

01/27/2021, 5:46 PM
I’m thinking you can set a variable before agwConfig that defines the autoscaleConfiguration object and then use that value in the agwConfig setting. E.g.
Copy code
const autoscaleConfig = (useAppGaeayAutoScale ? {minCapacity: appGatewayAutoScaleMinimumInstanceCount, maxCapacity: appgatewayAutoScaleMaximumInstanceCount} : {})

let agwConfig ... = {
   ...
autoscaleConfiguration: autoscaleConfig
}
q

quiet-hairdresser-18834

01/27/2021, 6:10 PM
close! I think this works:
Copy code
const autoscaleConfig = (useAppGatewayAutoScale ? {minCapacity: appGatewayAutoScaleMinimumInstanceCount, maxCapacity: appGatewayAutoScaleMaximumInstanceCount} : undefined)
(just the last bit changed to undefined instead of {} object)