Fork me on GitHub
#aws
<
2023-01-11
>
Loic07:01:06

Hi, I am using the cognitect-labs/aws-api to deploy my resources on my AWS account. However, I have issue with the :Tags. The resource is created but without the tags.

(aws/invoke ec2-client {:op :CreateVpc
                        :request {:CidrBlock "192.168.0.0/16"
                                  :Tags [{:Key "Name" :Value "my-vpc"}]}})
I tried with CreateSubnet, CreateInternetGateway etc, still the same result. Am I missing something?

Bingen Galartza Iparragirre08:01:27

According to the docs the CreateVPC API operation doesn't have a "Tags" option. You can check it in the docs site: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVpc.html It has something called "TagSpecification" which maybe is what you need? (never used it myself)

Bingen Galartza Iparragirre08:01:30

You can also run (aws/doc ec2-client :CreateVpc) to see the exact Clojure data structure that the aws-api client expects

Loic08:01:50

The aws/doc or aws/op both show a Tags param:

{:Vpc
 {:Tags [:seq-of {:Key string, :Value string}],
  :IsDefault boolean,
  :InstanceTenancy [:one-of ["default" "dedicated" "host"]],
  :CidrBlock string,
  ...
  :VpcId string}}

Loic08:01:45

And when I :DescribeVpcs with Name tag I manually added via the Console, they do show in a :Tags param with same syntax as I tried above.

Bingen Galartza Iparragirre08:01:21

The aws/doc command shows both the Request and the Response. I can only see Tags in the Response section.

Loic09:01:08

Oh got it:

(aws/invoke ec2-client {:op :CreateVpc
                        :request {:CidrBlock "192.168.0.0/16"
                                  :TagSpecifications [{:ResourceType "vpc"
                                                       :Tags [{:Key "Name" :Value "my-vpc"}]}]}})
You were right, TagSpecification is what I needed. I just had to add the mandatory ResourceType Thank you

kouvas19:01:49

Is there already a way to easily convert a dynamoDB response map with types to one without?

👀 2
Dimitar Uzunov10:01:15

Which API are you using? There should be methods to marshall and unmarshall dynamodb JSON

kouvas18:01:42

Cognitect's api, don't see support for marhsalling

kouvas21:01:08

I see amazonica's ddb client supports marhalling

Dimitar Uzunov22:01:48

or if you use interop with JS or Java

dchelimsky11:01:52

@UBTMXD33J I'm not sure what you're after here. What response are you getting and what do you want it to be?

kouvas23:01:40

I was looking if something like this https://github.com/ctorrisi/franklin/blob/master/src/franklin/core.clj#L56-L72 was already available

👍 2