Skip to content

V4: Fixed an issue where NullReferenceException was thrown while invoking AmazonCloudFormationClient.UpdateStackAsync(). #3835

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"services": [
{
"serviceName": "CloudFormation",
"type": "patch",
"changeLogMessages": [ "Fixed an issue where NullReferenceException was thrown while invoking AmazonCloudFormationClient.UpdateStackAsync()." ]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ protected virtual void PreInvoke(IExecutionContext executionContext)
if (updateStackRequest != null)
{
var arns = updateStackRequest.NotificationARNs;
bool arnsAutoConstructed = arns is AutoConstructedList<string>;

// 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<string>))
{
if (request.Parameters.ContainsKey("NotificationARNs"))
{
request.Parameters["NotificationARNs"] = string.Empty;
}
else
{
request.Parameters.Add("NotificationARNs", string.Empty);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Parameter>
{
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<Parameter>
{
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<Parameter>
{
new Parameter
{
ParameterKey = "TopicName",
ParameterValue = "MyTopic" + DateTime.UtcNow.Ticks
},
new Parameter
{
ParameterKey = "QueueName",
ParameterValue = "MyQueue" + DateTime.UtcNow.Ticks
}
},
NotificationARNs = new List<string>()
};
Client.UpdateStack(updateStackRequest);
WaitTillStackNotInProcess(stackName);
}
finally
{
WaitTillStackNotInProcess(stackName);
Client.DeleteStack(new DeleteStackRequest() { StackName = stackName });
}
}

static void WaitTillStackNotInProcess(string stackname)
{
DescribeStacksResponse response = null;
Expand Down