rhythmic-branch-12845
11/22/2022, 7:31 AMstr
? I know that the YAML spec allows for specifying an “int” type, which I’ve done in `Pulumi.dev.yaml`:
config:
test:az_count: !!int 3
I’ve tested PyYAML and read back the YAML and confirmed that test:az_count
is read back as an int, but when I try in Pulumi to get the config, I get an str instead:
error: Program failed with an unhandled exception:
Traceback (most recent call last):
File "/Users/jf/.../pulumi/./__main__.py", line 37, in <module>
for i in range(0, vars.az_count):
TypeError: 'str' object cannot be interpreted as an integer
here’s `vars.py`:
import pulumi
config = pulumi.Config()
az_count = config.get('az_count')
I’ve found 2 workarounds, but honestly I am disappointed and would expect that config.get
would just return you the right type:
1. use config.get_int()
so that you dont even need to (in fact it does not matter!) specify !!int 3
2. use int()
on the value u read back from config.get()
early-analyst-76866
11/22/2022, 5:24 PMrhythmic-branch-12845
11/23/2022, 12:00 PMvictorious-exabyte-70545
11/23/2022, 8:35 PMrhythmic-branch-12845
11/24/2022, 7:57 AMvpc
project, to another project that needs the list of subnet ids.
Based on https://www.pulumi.com/docs/reference/pkg/python/pulumi/#stack-exports-1 and seeing pulumi.export(_name: str_, _value: Any_)
, I was thinking that I could export a list… but nope:
pulumi:pulumi:Stack (acm-us):
error: Program failed with an unhandled exception:
Traceback (most recent call last):
File "/Users/jf/.../pulumi/acm/./__main__.py", line 40, in <module>
pulumi.export(cert_arns, cert_arns)
File "/Users/jf/.../pulumi/venv/lib/python3.10/site-packages/pulumi/resource.py", line 1282, in export
res.output(name, value)
File "/Users/jf/.../pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 158, in output
self.outputs[name] = value
TypeError: unhashable type: 'list'
UPDATE: this has been resolved. A big thank you to @billowy-army-68599 for the help! Looking back at the code above again, I also see where I went wrong: pulumi.export(cert_arns, cert_arns)
should have been pulumi.export("cert_arns", cert_arns)
! argh….mammoth-memory-9424
11/24/2022, 3:49 PMtrigger = Trigger(
resource_name="pulumi-trigger",
filename="Dockerfile",
trigger_template=TriggerTriggerTemplateArgs(
repo_name="my_repo",
tag_name="tag-*",
),
)
Unfortunately, I can not find how to configure this trigger using a dockerfile (a google cloud config file is expected instead).
I would like to do something that behaves exactly as :
gcloud beta builds triggers create cloud-source-repositories --repo my_repo --tag-pattern tag-* --dockerfile Dockerfile --name pulumi-trigger
Any idea how to do so ? the API reference has just got me lost so farrhythmic-branch-12845
11/27/2022, 12:51 PMNone
instead? I’m seeing that at the command line, pulumi has no issues with `pulumi config get aws:region`… so I try to do the same with config.get('aws:region')
, but for some reason I get None
(verified using print()
)clever-painter-96148
11/29/2022, 11:24 AMimport {config} from '@pulumi/gcp';
const foo = `${config.project}/${config.zone}`;
How to I achieve the same in Python?clever-painter-96148
11/29/2022, 2:10 PMrefined-carpet-42005
12/01/2022, 9:51 AMpulumi up
):
Diagnostics:
pulumi:pulumi:Stack (<my-stack>):
/Users/<my-path>/venv/lib/python3.10/site-packages/grpc/_server.py:456: RuntimeWarning: coroutine 'invoke.<locals>.do_rpc' was never awaited
return None, False
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
pulumi-python:dynamic:Resource (foo):
error: Exception calling application: There is no current event loop in thread 'ThreadPoolExecutor-0_0'.
and I had no issues with my stack before adding my Dynamic Provider. I've tried with multiple providers but not even the simple Random
example from the documentationdry-keyboard-94795
12/02/2022, 3:13 PM.get()
outputs or Stackreferences, how safe would something like this be (which does work for k8s `ConfigMap.get()`:
import typing
import pulumi
from pulumi.runtime.sync_await import _sync_await
T_co = typing.TypeVar("T_co", covariant=True)
def extract(o: pulumi.Output[T_co]) -> T_co:
if not _sync_await(o.is_known()):
raise RuntimeError("Output is not known yet")
return _sync_await(o.future())
(using the hidden _sync_await
for convenience to lift out an awaitable)thousands-lizard-52998
12/03/2022, 3:31 PMminiature-musician-31262
12/08/2022, 3:29 PMdry-keyboard-94795
12/08/2022, 4:13 PMclever-painter-96148
12/15/2022, 12:51 PMminiature-gigabyte-99238
12/17/2022, 1:58 PMcalm-doctor-66000
12/21/2022, 4:57 PMconfig = pulumi.Config()
X_CP_API_ID = config.require_secret('X_CP_API_ID')
X_CP_API_KEY = config.require_secret('X_CP_API_KEY')
X_ECM_API_ID = config.require_secret('X_ECM_API_ID')
X_ECM_API_KEY = config.require_secret('X_ECM_API_KEY')
cradlepoint_api = {
"X-CP-API-ID": X_CP_API_ID,
"X-CP-API-KEY": X_CP_API_KEY,
"X-ECM-API-ID": X_ECM_API_ID,
"X-ECM-API-KEY": X_ECM_API_KEY,
"Content-Type":"application/json"
}
cradlepoint_secret = aws.secretsmanager.Secret("lambda/cradlepoint_api")
cradlepoint_secret_version = aws.secretsmanager.SecretVersion("lambda/cradlepoint_api",
secret_id = cradlepoint_secret.arn,
secret_string = str(cradlepoint_api)
)
Thanks!millions-pharmacist-626
12/22/2022, 7:01 PM__main__.py
modules from parent directories.
Mostly the solutions that have been suggested are:
• Either hack sys.path in some way or another,
• Install the pulumi repo itself as a package as described in this thread
I was wondering if in the meantime, someone had come up with a preferrable solutionpurple-market-1813
12/22/2022, 9:23 PMclever-painter-96148
12/24/2022, 10:49 AMclever-painter-96148
12/24/2022, 5:52 PMbroad-morning-80838
12/24/2022, 10:54 PMpulumi stack --show-urns
broad-morning-80838
12/24/2022, 10:57 PMbillions-shoe-26601
12/28/2022, 8:52 AMaverage-ambulance-11866
12/29/2022, 7:35 PMbillions-shoe-26601
12/30/2022, 3:55 PMaverage-ambulance-11866
01/05/2023, 5:54 AMvictorious-exabyte-70545
01/05/2023, 8:51 PMuser_assigned_identity = azure.authorization.UserAssignedIdentity(
f"{stack_name}-identity",
name=f"{stack_name}-identity",
location=resource_group.location,
resource_group_name=resource_group.name,
tags=tags)
azure.compute.Extension(
"KeyVaultExtension",
name="KeyVaultExtension",
virtual_machine_id=vm.id,
publisher="Microsoft.Azure.KeyVault",
type="KeyVaultForLinux",
type_handler_version="2.0",
settings=json.dumps(
{
"secretsManagementSettings": {
"pollingIntervalInS": "30",
"certificateStoreName": "MY",
"linkOnRenewal": False,
"certificateStoreLocation": "/var/lib/waagent/Microsoft.Azure.KeyVault",
"observedCertificates": [
f"{kv_uri}/secrets/certificate",
f"{kv_uri}/secrets/certificate"
]
},
"authenticationSettings": {
"msiEndpoint": "<http://169.254.169.254/metadata/identity>",
"msiClientId": user_assigned_identity.client_id
}
}
),
opts=ResourceOptions(
depends_on=[vm]
)
)
bland-pharmacist-96854
01/08/2023, 4:37 PMbland-pharmacist-96854
01/09/2023, 6:33 PM