https://pulumi.com logo
Title
f

flat-animal-59128

04/13/2023, 6:54 PM
Hello, what is the correct way to form tags for the aws native api
import pulumi_aws_native as aws_native
The tagging functionality format does not accept the same format I use in the classic api. for example using
aws_tags = {
    'function': cfg.get('function'),
    'application': cfg.get('application')}
has worked in the aws classic but this aws_native keeps erroring
ds_s3_resource_bucket = aws_native.s3.Bucket(resource_name= ds_well_comm_base_name
                                            , bucket_name= ds_well_comm_base_name
                                            , access_control = 'Private'
                                            , tags= aws_tags)
keeps erroring
error: aws-native:s3:Bucket resource 'ds-well-comm-base': property tags[0].Key value {<nil>} has a problem: unknown property tags[0].Key
    error: aws-native:s3:Bucket resource 'ds-well-comm-base': property tags[0].Value value {<nil>} has a problem: unknown property tags[0].Value
I have tried other formats like a list of jsons. tags=[json.dumps({ 'function': cfg.get('function')}) but get errors like
...problem: tags[0] must be an object
or
...problem: tags must be an array
I know I can use boto3 to add tags but that sems to defeat the purpose of pulumi.
s3_client = boto3.client('s3')

s3_client.put_bucket_tagging(
    Bucket=ds_well_comm_base_name
    , Tagging={
        'TagSet': [
            {
                'Key': 'string',
                'Value': 'string'
            },
        ]
    }
)
b

billowy-army-68599

04/13/2023, 7:38 PM
I think you just need to set the
Key
and
Value
the same as boto
aws_tags = [
    { 'Key': function, 'Value': cfg.get('function') }],
f

flat-animal-59128

04/13/2023, 8:42 PM
Unfortunately that is one of the formulations I have tried.
ds_s3_resource_bucket = aws_native.s3.Bucket(resource_name= ds_well_comm_base_name
                                            , bucket_name= ds_well_comm_base_name
                                            , access_control = 'Private'
                                            , tags= [
                                                    {
                                                        'Key': 'string',
                                                        'Value': 'string'
                                                    },
                                                ]
                                            )
Gives this error
aws-native:s3:Bucket (ds-well-comm-base-dev):
    error: aws-native:s3:Bucket resource 'ds-well-comm-base-dev': property tags[0].Key value {<nil>} has a problem: unknown property tags[0].Key
    error: aws-native:s3:Bucket resource 'ds-well-comm-base-dev': property tags[0].Value value {<nil>} has a problem: unknown property tags[0].Value
b

billowy-army-68599

04/13/2023, 8:51 PM
hmm, could you open an issue?
f

flat-animal-59128

04/13/2023, 9:18 PM
@billowy-army-68599 out of curiosity I tried to get a result as seen in the error. Using namedtuples I was able to get something akin to the error displayed but the namedtuple object still creates an error during build. The local py check is the image where
my_tags[0].Value
has a value The error received from pulumi was an unhandled execption
ValueError: unexpected input of type Tag