https://pulumi.com logo
Title
a

able-hospital-16256

12/21/2022, 4:23 PM
How aws.ssm.Association receive params?, I’m giving him a list but it returns an error about Mapping 😒ad-panda:
parameters=[
"mkdir FileTestSSM3",
],
l

little-cartoon-10569

12/21/2022, 7:01 PM
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

able-hospital-16256

12/21/2022, 7:50 PM
For aws-native receive an object but in aws-classic doesn’t accept it
😒ad-panda:
l

little-cartoon-10569

12/21/2022, 8:06 PM
It does, usually. The two libraries are compatible. What's the specific problem you're having?
a

able-hospital-16256

12/21/2022, 8:08 PM
@little-cartoon-10569 This is the error
l

little-cartoon-10569

12/21/2022, 8:56 PM
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

able-hospital-16256

12/21/2022, 9:05 PM
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

little-cartoon-10569

12/21/2022, 9:32 PM
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

able-hospital-16256

12/21/2022, 9:40 PM
@little-cartoon-10569 Do you have an example pls? 🙏
l

little-cartoon-10569

12/21/2022, 9:42 PM
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/
import pulumi
import pulumi_aws as aws

example = aws.ssm.Association("example", targets=[aws.ssm.AssociationTargetArgs(
    key="InstanceIds",
    values=[aws_instance["example"]["id"]],
)])
a

able-hospital-16256

12/21/2022, 9:42 PM
Yeah, but I need to use parameters, with this library i can’t?
I see the error in the targets :l
l

little-cartoon-10569

12/21/2022, 9:43 PM
Why not? parameters isn't the same parameter as targets.
@overload
def Association(resource_name: str,
...
                parameters: Optional[Mapping[str, str]] = None,
...
                targets: Optional[Sequence[AssociationTargetArgs]] = None,
...
a

able-hospital-16256

12/21/2022, 9:46 PM
The problem is not in the targets, is on parameters
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

little-cartoon-10569

12/21/2022, 9:55 PM
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

able-hospital-16256

12/21/2022, 9:57 PM
You were right, the problem was that i use ” ” instead of ' '
l

little-cartoon-10569

12/21/2022, 9:59 PM
Ah. Python isn't my strong point. Well done on figuring it out.
a

able-hospital-16256

12/21/2022, 10:00 PM
Thanks bro! 🙏 :thank-you: