sparse-intern-71089
11/01/2022, 1:58 AMminiature-musician-31262
11/01/2022, 4:23 AMminiature-musician-31262
11/01/2022, 4:36 AMsome_dict = {
"THING": "one",
"OTHER_THING": 2,
}
fn = aws.lambda_.Function("fn",
runtime="python3.9",
handler="handler.handler",
role=role.arn,
code=pulumi.FileArchive("./function"),
environment=aws.lambda_.FunctionEnvironmentArgs(
variables=some_dict,
))
miniature-musician-31262
11/01/2022, 4:37 AMorange-airport-64592
11/01/2022, 5:54 AMsome_dict = {
"THING": "one",
"OTHER_THING": 2,
}
fn = aws.lambda_.Function("fn",
runtime="python3.9",
handler="handler.handler",
role=role.arn,
code=pulumi.FileArchive("./function"),
environment=aws.lambda_.FunctionEnvironmentArgs(
variables=some_dict,
))
I can not understand, It looks like my codes, but it works! Just eluded pylance’s inspection?orange-airport-64592
11/01/2022, 6:01 AMminiature-musician-31262
11/01/2022, 3:15 PMs3_zip_log_bucket_name
and db_password
values coming from, though? Are they plain strings, or outputs of some other resource?fierce-ability-58936
11/01/2022, 9:34 PM...
"RDS_PORT": "3306",
"TTL": "172800",
...
these will be env vars anyway, so they will be strings.fierce-ability-58936
11/01/2022, 9:38 PMvariables = {
"DESTN_BUCKET": "blah",
"RDS_HOSTNAME": "<http://xxxx.ap-east-1.rds.amazonaws.com|xxxx.ap-east-1.rds.amazonaws.com>",
"RDS_USERNAME": "admin",
"RDS_PASSWORD": "blah",
"RDS_PORT": "3306",
"TTL": 172800,
}
then it works.
It seems, the variables type is inferred as dict[str, Unknown]
variables = {
"DES (variable) variables: dict[str, Unknown]
but if you define the type properly, then it becomes an error:
variables: dict[str, str] = {
"DESTN_BUCKET": "blah",
"RDS_HOSTNAME": "<http://xxxx.ap-east-1.rds.amazonaws.com|xxxx.ap-east-1.rds.amazonaws.com>",
"RDS_USERNAME": "admin",
"RDS_PASSWORD": "blah",
"RDS_PORT": "3306",
E "TTL": 172800, ■ Expression of type "dict[str, str | int]" cannot be assigned to declared type "dict[str, str]" "Literal[172800]" is incompatible with "str"
}
Add quotes to TTL and it works 🙂fierce-ability-58936
11/01/2022, 9:45 PMInput[str]
as either str
or Output[str]
In fact, in the SDK it's defined as a Union
Input = Union[T, Awaitable[T], "Output[T]"]
orange-airport-64592
11/02/2022, 2:34 AMs3_zip_log_bucket_name
and db_password
values are string too, I find the key is
"TTL": 172800
When I remove this line, It is fine.orange-airport-64592
11/02/2022, 2:43 AMfierce-ability-58936
11/02/2022, 7:59 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by