A company has an AWS CloudFormation template that includes an AWS::EC2::Instance resource and a custom resource (Lambda function). The Lambda function fails because it runs before the EC2 instance is launched. Which solution will resolve this issue?
Option D seems possible since you can use Fn::If for some conditional logic in CloudFormation, but I think it's not really meant to control resource creation order. Fn::If mostly changes properties or whether something gets created, not the sequencing. Pretty sure this wouldn't actually fix the Lambda running too soon. If anyone's made this work differently let me know.
My vote is A is right here. The problem is all about the resource order, and DependsOn is how you make sure CloudFormation waits for the EC2 instance before launching the Lambda custom resource. D looks tempting but Fn::If doesn't guarantee resource creation order. Seen this in exam practice a few times, pretty sure it's A.