brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

[amazonka-certificatemanager] 200 OK but serialization error #874

Closed AngeloChecked closed 1 year ago

AngeloChecked commented 1 year ago

i done a simple script in order to summary my aws certificates:

cabal-version:      2.4
name:               myaws
version:            0.1.0.0

executable myaws
    main-is:          Main.hs
    build-depends:    base ^>=4.14.3.0, lens, amazonka, amazonka-certificatemanager
    hs-source-dirs:   app
    default-language: Haskell2010
module Main where

import Control.Lens
import Network.AWS
import Network.AWS.CertificateManager.ListCertificates
import Network.AWS.CertificateManager.DescribeCertificate
import System.IO
import Network.AWS.CertificateManager (csCertificateARN)
import Data.Maybe

main :: IO ()
main = do
    certs <- listCertificatesRequest
    let certificateSummaryList =    certs ^. lcrsCertificateSummaryList
    let certArns = catMaybes $ (^. csCertificateARN) <$> certificateSummaryList
    certDescriptions <- traverse describeCertificateRequest certArns
    let certs = (^. dcrsCertificate) <$> certDescriptions
    print certs

commonRequest request = do
    lgr  <- newLogger Debug stdout
    env  <- newEnv Discover
    runResourceT $ runAWS (env & envLogger .~ lgr) $
        within Ireland $
            send request

listCertificatesRequest :: IO ListCertificatesResponse
listCertificatesRequest  = do
    commonRequest listCertificates

describeCertificateRequest arn = do
    commonRequest $ describeCertificate arn

i receive this error:

[SerializeError] {
  service = CertificateManager
  status  = 200 OK
  message = Error in $.KeyAlgorithm: Failed reading: Failure parsing KeyAlgorithm from value: 'rsa-2048'. Accepted values: ec_prime256v1, ec_secp384r1, ec_secp521r1, rsa_1024, rsa_2048, rsa_4096
  body    = Just {"Certificate":{"CertificateArn":"arn:aws:acm:eu-west-1:3
....

In the log i can see the whole response of the service and it's correct with 200. But the program terminate with an error. I don't understand the problem. There a library problem or i done wrong something? i'm using ghcup, cabal 3.6.2 and ghc 8.10.7 (i'm a haskell noob)

endgame commented 1 year ago

Amazonka 1.6.1 has a very strict parser when it comes to enums, and will throw if it sees a value that it doesn't expect. This affects things like EC2 instance types, as well as AWS regions, etc. 1.6.1 is many years out of date and there will be no more releases in the 1.6 line.

Use the latest commit on main, following the instructions in the 2.0RC1 release announcement. 2.0 has much better sum type handling, in that it doesn't explode when presented with new enum value, and also the ACM bindings will be new enough to have a binding for that Key algorithm. I hope to tag 2.0RC2 soon, and get something up on Hackage some time after that.

endgame commented 1 year ago

P.S.: Since you said you were new, I thought I might offer some tips:

Feel free to reply here if you have further questions.