Skip to content

Commit e6577e1

Browse files
authored
Use Aspire 9's WaitFor feature for making projects wait for CloudFormation (#14)
1 parent 371d00a commit e6577e1

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Aspire.Hosting.AWS",
5+
"Type": "Patch",
6+
"ChangelogMessages": [
7+
"Use Aspire 9's WaitFor mechanism for waiting CloudFormation resource to be running"
8+
]
9+
}
10+
]
11+
}

src/Aspire.Hosting.AWS/CloudFormation/CloudFormationExtensions.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,16 @@ public static IResourceBuilder<TDestination> WithReference<TDestination>(this IR
149149
/// <param name="configSection">The config section in IConfiguration to add the output parameters.</param>
150150
/// <returns></returns>
151151
public static IResourceBuilder<TDestination> WithReference<TDestination>(this IResourceBuilder<TDestination> builder, IResourceBuilder<ICloudFormationResource> cloudFormationResourceBuilder, string configSection = Constants.DefaultConfigSection)
152-
where TDestination : IResourceWithEnvironment
152+
where TDestination : IResourceWithEnvironment, IResourceWithWaitSupport
153153
{
154154
if (!cloudFormationResourceBuilder.Resource.Annotations.Any(x => x is CloudFormationReferenceAnnotation cf && string.Equals(cf.TargetResource, builder.Resource.Name, StringComparison.Ordinal)))
155155
{
156156
cloudFormationResourceBuilder.WithAnnotation(new CloudFormationReferenceAnnotation(builder.Resource.Name));
157157
}
158158

159-
builder.WithEnvironment(async ctx =>
159+
builder.WaitFor(cloudFormationResourceBuilder);
160+
161+
builder.WithEnvironment(ctx =>
160162
{
161163
if (ctx.ExecutionContext.IsPublishMode)
162164
{
@@ -168,12 +170,6 @@ public static IResourceBuilder<TDestination> WithReference<TDestination>(this IR
168170
SdkUtilities.ApplySDKConfig(ctx, cloudFormationResourceBuilder.Resource.AWSSDKConfig, false);
169171
}
170172

171-
if (cloudFormationResourceBuilder.Resource.ProvisioningTaskCompletionSource is not null)
172-
{
173-
ctx.Logger?.LogInformation("Waiting on CloudFormation resource {Name} ...", cloudFormationResourceBuilder.Resource.Name);
174-
await cloudFormationResourceBuilder.Resource.ProvisioningTaskCompletionSource.Task.WaitAsync(ctx.CancellationToken).ConfigureAwait(false);
175-
}
176-
177173
if (cloudFormationResourceBuilder.Resource.Outputs == null)
178174
{
179175
return;

0 commit comments

Comments
 (0)