Coder Social home page Coder Social logo

Unknow error on aws iot about aws-elixir HOT 13 CLOSED

aws-beam avatar aws-beam commented on August 18, 2024
Unknow error on aws iot

from aws-elixir.

Comments (13)

RandomGuy2020 avatar RandomGuy2020 commented on August 18, 2024 2

I used the version 6. The input was wrong I had to:
input = %{policyDocument: test}
with test = Poison.encode!(%{
"Version": "2012-10-17",
"Statement": [
%{
"Effect": "Allow",
"Action": [
"iot:Publish",
"iot:Receive"
],
"Resource": [
"arn:aws:iot:us-west-2:000000000000:topic/topic_1",
"arn:aws:iot:us-west-2:000000000000:topic/topic_2"
]
},
%{
"Effect": "Allow",
"Action": [
"iot:Subscribe"
],
"Resource": [
"arn:aws:iot:us-west-2:000000000000:topicfilter/topic_1",
"arn:aws:iot:us-west-2:000000000000:topicfilter/topic_2"
]
},
%{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"arn:aws:iot:us-west-2:000000000000:client/basicPubSub"
]
}
]
})

I put the problem on solve thanks for your time

from aws-elixir.

philss avatar philss commented on August 18, 2024

Hi, @RandomGuy2020! Thanks for opening the issue.
The input value is a policy like the one in the example: https://docs.aws.amazon.com/cli/latest/reference/iot/create-policy.html#examples

We are investigating how to improve our docs to include some examples like these.

from aws-elixir.

RandomGuy2020 avatar RandomGuy2020 commented on August 18, 2024

Thanks for you quick reply! I'm very sorry but i'm very bad and it doesn't work when you will have time could you see the code below and say to me what's is wrong ?
Here is the code (I replace the 000000000000 by my id account) :
`
client1 = initClient()

input = %{
"Version": "2012-10-17",
"Statement": [
    %{
        "Effect": "Allow",
        "Action": [
            "iot:Publish",
            "iot:Receive"
        ],
        "Resource": [
            "arn:aws:iot:us-west-2:000000000000:topic/topic_1",
            "arn:aws:iot:us-west-2:000000000000:topic/topic_2"
        ]
    },
    %{
        "Effect": "Allow",
        "Action": [
            "iot:Subscribe"
        ],
        "Resource": [
            "arn:aws:iot:us-west-2:000000000000:topicfilter/topic_1",
            "arn:aws:iot:us-west-2:000000000000:topicfilter/topic_2"
        ]
    },
    %{
        "Effect": "Allow",
        "Action": [
            "iot:Connect"
        ],
        "Resource": [
            "arn:aws:iot:us-west-2:000000000000:client/basicPubSub"
        ]
    }
]

}

AWS.IoT.create_policy(client1, "testelixir", input)

`

Thanks you for your time 😄

from aws-elixir.

philss avatar philss commented on August 18, 2024

@RandomGuy2020 I think you need to send the input as a JSON string, because it won't be converted automatically. Can you give a try and check if works?

PS: you have Poison available, so you can encode as the docs suggest: https://github.com/devinus/poison#usage

from aws-elixir.

RandomGuy2020 avatar RandomGuy2020 commented on August 18, 2024

It doesn't work too when I use

input=Poison.encode!(...)

And the error is still {:error, nil}

from aws-elixir.

philss avatar philss commented on August 18, 2024

@RandomGuy2020 can you try to create the same policy using AWS console?
Also, do you see warnings when you try to create the policy?

from aws-elixir.

RandomGuy2020 avatar RandomGuy2020 commented on August 18, 2024

It's working on aws console and I don't have warning

from aws-elixir.

philss avatar philss commented on August 18, 2024

OK, thank you! One more try: would you mind to use the GitHub version and see if works?
Just change your mix.exs to point to this repository: {:aws, github: "aws-beam/aws-elixir"}.

from aws-elixir.

RandomGuy2020 avatar RandomGuy2020 commented on August 18, 2024

Ok now I have an error 400, when I let the Poison.encode!(..) I don't have a message for the error but when I remove it I always have an error 400 but the body error is : "message":"1 validation error detected: Value null at 'policyDocument' failed to satisfy constraint: Member must not be null"

from aws-elixir.

philss avatar philss commented on August 18, 2024

@RandomGuy2020 cool! We got something :D

I have an idea that is to use another HTTP client and log the request/response. Tesla has this middleware that logs the request, so we can use that to inspect what is going on. But the process of configuring another HTTP client is not documented yet (it was introduced in #42), so I will try to document it first.

from aws-elixir.

RandomGuy2020 avatar RandomGuy2020 commented on August 18, 2024

I want to add the get_policy doesnt work with {:aws, github: "aws-beam/aws-elixir"} they say : The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
But it's working on the version 6

from aws-elixir.

tejpochiraju avatar tejpochiraju commented on August 18, 2024

@RandomGuy2020 - I am getting the same error The request signature we calculated does not match the signature you provided. when calling AWS.IoT.list_things.

The client works fine for AWS.S3 queries. I have been trying a few versions of aws-elixir to see which one works but haven't been able to identify one yet. When you refer to version 6 do you mean the release 0.6.0?

I will open a new issue if your response does not resolve it.

from aws-elixir.

philss avatar philss commented on August 18, 2024

@tejpochiraju did you try the version from GitHub (the master branch)?

from aws-elixir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.