Open allixsenos opened 2 years ago
Thanks for opening an issue. This is definitely something we are thinking about! I think you can abuse Fn::ToJSON
as a work around right now. It will cast numbers to strings.
Define your variables as numbers:
variables:
AppListenPort: 8000
HaproxyListenPort: 8080
and then cast them to strings by passing them to Fn::ToJSON
:
resources:
TaskDefinition:
type: aws-native:ecs:TaskDefinition
properties:
containerDefinitions:
- name: haproxy
portMappings:
- containerPort: ${HaproxyListenPort}
hostPort: ${HaproxyListenPort}
environment:
- name: HAPROXY_APP_PORT
value:
Fn::ToJSON: ${AppListenPort}
- name: HAPROXY_LISTEN_PORT
value:
Fn::ToJSON: ${HaproxyListenPort}
@iwahbe I have a customer with a need of going from string to integer. In below snippet, the stdout
from command:local:run
is typed string
. Now the string represents an integer and it should be passed as type integer
to the Redis instance:
variables:
redisSize:
fn::invoke:
function: command:local:run
arguments:
command: yq ".${env}.redisSize" < extra-vars.yaml
return: stdout
resources:
redis:
type: gcp:redis:Instance
properties:
memorySizeGb: ${redisSize}
...
A toNumber
and toBool
function would be handy.
CC @pulumi/platform for ☝️
Hello!
Issue details
Some AWS constructs are very sensitive about their datatypes (number vs string).
aws:lb:TargetGroup properties.port
expects a number, complains if it's a string, expects a numberaws-native:ecs:TaskDefinition properties.containerDefinitions.portMappings.containerPort
(and .hostPort) complain if it's a string, expect a numberbut ...
aws-native:ecs:TaskDefinition properties.containerDefinitions.environment.value
(and .hostPort) will complain if it's a numberI would like to feed the same variable into both portMappings and environment. I haven't found a better way than defining the same variable twice, with String appended to the name of the second one, and wrapping it in quotes :(
like so:
so that I can
Affected area/feature