worried-xylophone-86184
02/23/2022, 1:42 PMapply
and all
function the individual values are supposed to be accessed. This makes sense when the values are being passed on to another Cloud resource. Function calls and traceback are in the thread. What is supposed to be done when the values are supposed to extracted from the Output
object and used for a non Pulumi operation like making POST calls?
I found an alternative where the output is being written to file def set_request_data_headers(args):
data = pulumi.Output.all(args.get("cluster_name"), args.get("cluster_url"),).apply(
lambda parameters: json.dumps(
{
"CLUSTER_NAME": parameters[0],
"CLUSTER_URL": parameters[1],
}
)
)
headers = {
"Authorization": args.get("token"),
}
return data, headers
register_cluster_with_argocd calls the above function
def register_cluster_with_argocd(args):
data, headers = set_request_data_headers(args)
pulumi.export("Data", data)
pulumi.export("Headers", headers)
response = <http://requests.post|requests.post>(
"SOME_URL",
headers=headers,
data=data,
)
return response
File "VIRTUAL_ENV_PATH/./aws/main.py", line 23, in create
response = argocd.register_cluster_with_argocd(argocd_registration_args)
File "VIRTUAL_ENV_PATH/./cluster_bootstrapping/argocd.py", line 34, in register_cluster_with_argocd
response = <http://requests.post|requests.post>(
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/requests/sessions.py", line 515, in request
prep = self.prepare_request(req)
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/requests/sessions.py", line 443, in prepare_request
p.prepare(
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/requests/models.py", line 321, in prepare
self.prepare_body(data, files, json)
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/requests/models.py", line 498, in prepare_body
self._body_position = body.tell()
TypeError: 'Output' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sushantk/.pulumi/bin/pulumi-language-python-exec", line 107, in <module>
loop.run_until_complete(coro)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 110, in run_in_stack
await run_pulumi_func(lambda: Stack(func))
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 45, in run_pulumi_func
await wait_for_rpcs()
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 94, in wait_for_rpcs
raise exception
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/pulumi/output.py", line 182, in run
transformed: Input[U] = func(value)
File "VIRTUAL_ENV_PATH/venv/lib/python3.8/site-packages/pulumi/output.py", line 231, in lift
return UNKNOWN if isinstance(v, Unknown) else getattr(v, item)
AttributeError: 'str' object has no attribute 'tell'
error: an unhandled error occurred: Program exited with non-zero exit code: 1
def register_cluster_with_argocd(args, cluster):
response = pulumi_command.local.Command(
"command-testing",
create=("curl "
"-H 'Authorization: {ARGO_TOKEN}' "
"-H 'X-Argo-E2E: true' "
"-H 'Content-Type: application/json; charset=UTF-8' "
"-d '{{'ARGOCD_CLUSTER_NAME': {CLUSTER_NAME}, "
"'CLUSTER_NAME': {CLUSTER_NAME}, "
"SOME_URL_TO_REGISTER_ARGO_CD").format(
CLUSTER_NAME=args.get("cluster_name"),
CLOUD_PROVIDER=args.get("cloud_provider"),
ENV=args.get("env"),
REGION=args.get("region"),
ARGO_TOKEN=args.get("argo_token")),
opts=pulumi.ResourceOptions(depends_on=[cluster]),
)
return response
Attaching the recorded API in the thread. But even though I have the EKS Cluster added as a dependsOn
parameter its not populating the real value.billowy-army-68599
02/28/2022, 6:08 PMapply
@worried-xylophone-86184pulumi.Output.all
inside your function, which isn't correctpulumi.Output.all
worried-xylophone-86184
03/02/2022, 10:38 AM