diff --git a/generator/.DevConfigs/66b6150c-da38-4673-9313-83bf9e38a90e.json b/generator/.DevConfigs/66b6150c-da38-4673-9313-83bf9e38a90e.json new file mode 100644 index 000000000000..1254453185d1 --- /dev/null +++ b/generator/.DevConfigs/66b6150c-da38-4673-9313-83bf9e38a90e.json @@ -0,0 +1,9 @@ +{ + "services": [ + { + "serviceName": "CloudFormation", + "type": "patch", + "changeLogMessages": [ "Fixed an issue where NullReferenceException was thrown while invoking AmazonCloudFormationClient.UpdateStackAsync()." ] + } + ] +} \ No newline at end of file diff --git a/sdk/src/Services/CloudFormation/Custom/Internal/ProcessRequestHandler.cs b/sdk/src/Services/CloudFormation/Custom/Internal/ProcessRequestHandler.cs index 361020a7ffec..f13047362273 100644 --- a/sdk/src/Services/CloudFormation/Custom/Internal/ProcessRequestHandler.cs +++ b/sdk/src/Services/CloudFormation/Custom/Internal/ProcessRequestHandler.cs @@ -68,13 +68,22 @@ protected virtual void PreInvoke(IExecutionContext executionContext) if (updateStackRequest != null) { var arns = updateStackRequest.NotificationARNs; - bool arnsAutoConstructed = arns is AutoConstructedList; - // if there are no NotificationARNs and the list was created by user (type is NOT AutoConstructed) - // only then pass empty param - if (arns.Count == 0 && !arnsAutoConstructed) + if (arns != null) { - request.Parameters.Add("NotificationARNs", ""); + // if there are no NotificationARNs and the list was created by user (type is NOT AutoConstructed) + // only then pass empty param + if (arns.Count == 0 && !(arns is AutoConstructedList)) + { + if (request.Parameters.ContainsKey("NotificationARNs")) + { + request.Parameters["NotificationARNs"] = string.Empty; + } + else + { + request.Parameters.Add("NotificationARNs", string.Empty); + } + } } } } diff --git a/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs b/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs index 5eade6eab7bc..b433a95dbd15 100644 --- a/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs +++ b/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs @@ -218,6 +218,86 @@ public void TestCreateStack() } } + [TestMethod] + [TestCategory("CloudFormation")] + public void TestUpdateStack() + { + string stackName = "test-stack-" + DateTime.UtcNow.Ticks; + try + { + CreateStackRequest createRequest = new CreateStackRequest + { + StackName = stackName, + TemplateBody = TEMPLATE_TEXT, + Parameters = new List + { + new Parameter + { + ParameterKey = "TopicName", + ParameterValue = "MyTopic" + DateTime.UtcNow.Ticks + }, + new Parameter + { + ParameterKey = "QueueName", + ParameterValue = "MyQueue" + DateTime.UtcNow.Ticks + } + } + }; + + Client.CreateStack(createRequest); + WaitTillStackNotInProcess(stackName); + + UpdateStackRequest updateStackRequest = new UpdateStackRequest + { + StackName = stackName, + TemplateBody = TEMPLATE_TEXT, + Parameters = new List + { + new Parameter + { + ParameterKey = "TopicName", + ParameterValue = "MyTopic" + DateTime.UtcNow.Ticks + }, + new Parameter + { + ParameterKey = "QueueName", + ParameterValue = "MyQueue" + DateTime.UtcNow.Ticks + } + } + }; + + Client.UpdateStack(updateStackRequest); + WaitTillStackNotInProcess(stackName); + + updateStackRequest = new UpdateStackRequest + { + StackName = stackName, + TemplateBody = TEMPLATE_TEXT, + Parameters = new List + { + new Parameter + { + ParameterKey = "TopicName", + ParameterValue = "MyTopic" + DateTime.UtcNow.Ticks + }, + new Parameter + { + ParameterKey = "QueueName", + ParameterValue = "MyQueue" + DateTime.UtcNow.Ticks + } + }, + NotificationARNs = new List() + }; + Client.UpdateStack(updateStackRequest); + WaitTillStackNotInProcess(stackName); + } + finally + { + WaitTillStackNotInProcess(stackName); + Client.DeleteStack(new DeleteStackRequest() { StackName = stackName }); + } + } + static void WaitTillStackNotInProcess(string stackname) { DescribeStacksResponse response = null;