This message was deleted.
# aws
s
This message was deleted.
l
It takes a map of keys to values. It's a single object (not an array) with each value having a name.
It's not used for passing documents, and script can is in documents. Passing commands like that, to documents that will execute whatever is passed into them, is probably a bad idea. There's no way sanitize your commands; a document that executes arbitrary input is an easy attack vector to abuse.
a
For aws-native receive an object but in aws-classic doesn’t accept it
sad panda
l
It does, usually. The two libraries are compatible. What's the specific problem you're having?
a
@little-cartoon-10569 This is the error
l
Urg, pictures of text. I don't think the error is coming from any of the pictures your posted. There's a type being used as a string, somewhere...
a
Copy code
example = aws.ssm.Association("specificInstanceIdAssociation", association_name="Test",
name="AWS-RunShellScript",targets=[aws_native.ssm.AssociationTargetArgs(                                 key="InstanceIds",                                  values=[                                   "*"],
)],
parameters={                            "commands": ["mkdir FileTestSSM3"],         "workingDirectory": ["/"],},)
I’m using it like this
l
Is that python?
Ah, yes I think your were right in your earlier comment:
For aws-native receive an object but in aws-classic doesn’t accept it
I had assumed you meant an output property of an AWS Native object wasn't being accepted as an AWS Classic input. You're constructing a object and passing it in its entirety. That is not supported.
You need to create a classic AssociationTargetArgs.
a
@little-cartoon-10569 Do you have an example pls? 🙏
l
You're doing the right thing, just using the wrong library for AssociationTargetArgs. The example in the docs is good: https://www.pulumi.com/registry/packages/aws/api-docs/ssm/association/
Copy code
import pulumi
import pulumi_aws as aws

example = aws.ssm.Association("example", targets=[aws.ssm.AssociationTargetArgs(
    key="InstanceIds",
    values=[aws_instance["example"]["id"]],
)])
a
Yeah, but I need to use parameters, with this library i can’t?
I see the error in the targets :l
l
Why not? parameters isn't the same parameter as targets.
Copy code
@overload
def Association(resource_name: str,
...
                parameters: Optional[Mapping[str, str]] = None,
...
                targets: Optional[Sequence[AssociationTargetArgs]] = None,
...
a
The problem is not in the targets, is on parameters
Copy code
raise AssertionError(f"Unexpected type. Expected 'list' got '{typ}'")
    AssertionError: Unexpected type. Expected 'list' got 'typing.Mapping[str, typing.Union[str, typing.Awaitable[str], pulumi.output.Output[NoneType]]]'
Receiving this error, I’m sending a list and it doesn’t works
l
Looks like Mapping class is something like
{'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
. So very similar to the typescript. You don't want to use array notation, just object notation.
And the right hand side can be an awaitable or an Output, but not an array.
You had
parameters={ "commands": ["mkdir FileTestSSM3"], "workingDirectory": ["/"],}
. Try
parameters={ "commands": "mkdir FileTestSSM3", "workingDirectory": "/",}
.
Though, providing commands via parameters is still not a great idea...
a
You were right, the problem was that i use ” ” instead of ' '
l
Ah. Python isn't my strong point. Well done on figuring it out.
a
Thanks bro! 🙏 🙏