I am getting an error creating a QLDB Stream from CDK using .NET. The CfnStream class requires a InclusiveStartTime property of type string, which is a UTC date in ISO8601 format. ex: 2019-11-05T13:15:30Z.
I am using the following code to get to this format but I have also tried specifying a regular string in the correct format. It didn't work either.
InclusiveStartTime = $"{DateTime.UtcNow.ToString("s")}Z"
This is the exception I am getting.
Unhandled exception. Amazon.JSII.Runtime.JsiiException: Resolution error: System.ArgumentException: Value has unexpected token type Date (Parameter 'value')
I tried replicating the same CDK stack using TypeScript and it worked.
namespace Cdk
{
public class MyStack : Stack
{
internal MyStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
CfnLedger qldb = new CfnLedger(this, "myLedger", new CfnLedgerProps{
Name = "myLedger",
PermissionsMode = "ALLOW_ALL"
});
Role QldbToKinesisRole = new Role(this, "qldbToKinesisRole", new RoleProps{
RoleName = "QldbToKinesisRole",
AssumedBy = new ServicePrincipal("qldb.amazonaws.com")
});
QldbToKinesisRole.AddManagedPolicy(ManagedPolicy.FromAwsManagedPolicyName("AmazonKinesisFullAccess"));
Stream qldbStream = new Stream(this, "qldbStream", new StreamProps{
StreamName = "MyKinesisStream",
ShardCount = 1
});
Amazon.CDK.AWS.QLDB.CfnStream qldbStreamConfig = new Amazon.CDK.AWS.QLDB.CfnStream(this, "qldbStreamConfig", new Amazon.CDK.AWS.QLDB.CfnStreamProps{
LedgerName = "myLedger",
StreamName = "MyKinesisStream",
InclusiveStartTime = $"{DateTime.UtcNow.ToString("s")}Z",
RoleArn = QldbToKinesisRole.RoleArn,
KinesisConfiguration = new Amazon.CDK.AWS.QLDB.CfnStream.KinesisConfigurationProperty{
AggregationEnabled = true,
StreamArn = qldbStream.StreamArn
}
});
}
}
}
I expected the cdk deploy command to succeed.
Unhandled exception. Amazon.JSII.Runtime.JsiiException: Resolution error: System.ArgumentException: Value has unexpected token type Date (Parameter 'value')
at Amazon.JSII.Runtime.Services.Converters.JsiiToFrameworkConverter.InferType(IReferenceMap referenceMap, Object value)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.ConvertAny(Type type, IReferenceMap referenceMap, Object value)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertPrimitive(Type type, IReferenceMap referenceMap, Object value, Boolean isOptional, PrimitiveType primitiveType, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, Type type, IReferenceMap referenceMap, Object value, Object& result)
at Amazon.JSII.Runtime.Services.Converters.JsiiToFrameworkConverter.TryConvertMap(IReferenceMap referenceMap, TypeReference elementTypeInstance, Object value, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertCollection(IReferenceMap referenceMap, Object value, Boolean isOptional, CollectionTypeReference collectionType, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, Type type, IReferenceMap referenceMap, Object value, Object& result)
at Amazon.JSII.Runtime.CallbackExtensions.<>c__DisplayClass2_0.<InvokeMethod>b__0(Int32 n)
at System.Linq.Enumerable.SelectRangeIterator`1.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeMethod(InvokeRequest request, IReferenceMap referenceMap)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallbackCore(Callback callback, IReferenceMap referenceMap)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallback(Callback callback, IReferenceMap referenceMap, IFrameworkToJsiiConverter converter, String& error).
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_0`1.<InvokeInstanceMethod>b__1(IClient client, Object[] args)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.CDK.Stage.Synth(IStageSynthesisOptions options)
at Cdk.Program.Main(String[] args) in /Users/tiagobar/Documents/GitHub/eventsourcing-qldb/cdk/src/Cdk/Program.cs:line 14
Subprocess exited with error 134
I see that there are other issues that seem related to this one 7392 and 5317
This is :bug: Bug Report
We have the same problem. We have tried multiple formats, and either get the same error during synth as the OP, or it fails during deploy when CloudFormation complains about the value being in the wrong format.
@t1agob thanks for reporting, can you share the regular string you've used? I'm not familiar with QLDB yet, but I'm going to start by trying to deploy the sample app. does an InclusiveStartTime with the values in the example succeed?
@peron - was your issue also specific to .NET or were you using another language?
@shivlaks no, the values in the example do not work. On the code I pasted when opening the issue I am getting the date in the specific format mentioned on the example but I have also tried to use a string like the one in the example. Got the same error.
@t1agob got it, thanks for confirming, I'll start with that example in TypeScript first and then build up. I'll provide an update once I take a look.
@shivlaks In Typescript it works without any issue. I moved all my CDK code from .Net to Typescript due to this issue.
@t1agob all right that saves me some debug time. so when using the same string value directly, does the failure occur during synthesis for .NET?
@shivlaks both synthesis and deploy. The stacktrace above is from a cdk deploy command.
The value appears to be round-trip-ing though a jsii Callback. I would not be surprised if the .NET JSON serializer actually deserializes the ISO-8601 string into a Date, and it's all broken from there on. I think this qualifies as a bug in the .NET runtime library for jsii.
My assumption was confirmed and I am looking to release the fix today 馃帀
I see you got around this quickly! So my answer might not be that important anymore, but yes, we also use .NET.
Since the problem occurred during synthesis, we ended up doing this in the stack file:
InclusiveStartTime = "<replace-me>"
and ended Program.Main with
app.Synth();
var fileName = $"./cdk.out/{stackName}.template.json";
var fileContents = File.ReadAllText(fileName);
fileContents = fileContents.Replace("<replace-me>", "2012-04-23T18:25:00Z");
File.WriteAllText(fileName, fileContents);
and that worked for us.
Most helpful comment
My assumption was confirmed and I am looking to release the fix today 馃帀