Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialisation: EC2:CreateVPC responses don't always include 'isDefault'. #214

Closed
fmap opened this issue Sep 8, 2015 · 4 comments
Closed

Comments

@fmap
Copy link
Contributor

fmap commented Sep 8, 2015

The following example:

{-# LANGUAGE FlexibleContexts  #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Lens (view, set)
import Control.Monad.Catch (MonadCatch)
import Control.Monad.Reader.Class (MonadReader)
import Control.Monad.Trans.AWS (Env, envLogger, newLogger, LogLevel(Trace), newEnv, Region(Singapore), Credentials(Discover), runAWST, Env, send)
import Control.Monad.Trans.Resource (MonadResource, runResourceT)
import Data.Functor ((<$>))
import Network.AWS.EC2 (VPC, createVPC, cvrsVPC)
import System.IO (stderr)

mkVPC :: MonadCatch m => MonadResource m => MonadReader Env m => m (Maybe VPC)
mkVPC = view cvrsVPC <$> send (createVPC "10.15.0.0/16") 

main :: IO ()
main = set envLogger <$> newLogger Trace stderr 
   >>= (<$> newEnv Singapore Discover)
   >>= runResourceT . flip runAWST mkVPC
    >> return ()

Currently fails on 'develop' citing:

[Raw Response Body] {
<?xml version="1.0" encoding="UTF-8"?>
<CreateVpcResponse xmlns="http://ec2.amazonaws.com/doc/2015-04-15/">
    <requestId>1007a025-e9e9-469d-b3e4-e8e2d6e79130</requestId>
    <vpc>
        <vpcId>vpc-86ac03e3</vpcId>
        <state>pending</state>
        <cidrBlock>10.15.0.0/16</cidrBlock>
        <dhcpOptionsId>dopt-e7339b8f</dhcpOptionsId>
        <instanceTenancy>default</instanceTenancy>
    </vpc>
</CreateVpcResponse>
}
[SerializeError] {
  service = EC2
  status  = 200 OK
  message = unable to find element "isDefault" in nodes ["vpcId","state","cidrBlock","dhcpOptionsId","instanceTenancy"]
}
*** Exception: SerializeError (SerializeError' {_serializeAbbrev = Abbrev "EC2", _serializeStatus = Status {statusCode = 200, statusMessage = "OK"}, _serializeMessage = "unable to find element \"isDefault\" in nodes [\"vpcId\",\"state\",\"cidrBlock\",\"dhcpOptionsId\",\"instanceTenancy\"]"})

The problem seems to be that the parser of VPC responses expects 'isDefault' to be present in results, while it isn't always(?).

@brendanhay
Copy link
Owner

Thanks for the example. It appears to have erroneously been added as an override.

@fmap
Copy link
Contributor Author

fmap commented Sep 8, 2015

Hah, I was just building the generator for fmapfmapfmap@9b4221f. :-)

The override seems to have been introduced here, but it's unclear what motivated it.

Thanks for the quick response! Let's see how it works out.

@brendanhay
Copy link
Owner

Yes, I also was unable to find reasoning for the addition from commits/memory. Quite alot of the EC2 overrides exist from my own codebases which run against non-standard regions. So it's quite possible they are wrong in the more general sense. #200 exists to try and improve the situation.

@fmap
Copy link
Contributor Author

fmap commented Sep 8, 2015

Cheers, 🎊.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants