Skip to content

(AWS.AppSync): Creation of CfnDomainNameApiAssociation fails when CfnDomainName object that association applies to is created under the same stack #18395

Closed
@TomaszCypser

Description

What is the problem?

Creation of CfnDomainNameApiAssociation and CfnDomainName that the previously mentioned object applies to fails, if is being done under the same stack. If I were to separate them into two different stacks, the error would not occur.

Reproduction Steps

  1. Create GraphqlApi instance.
  2. Setup domain name using this code snippet:
        [..]
            var certificate = new DnsValidatedCertificate(this, $"XXX-Api-Certificate",
                new DnsValidatedCertificateProps
                {
                    DomainName = props.DnsName,
                    Region = "us-east-1",
                    HostedZone = props.HostedZone
                });

            var cfnDomainName = new CfnDomainName(this, "XXX-Domain-Name",
                new CfnDomainNameProps
                {
                    CertificateArn = certificate.CertificateArn,
                    Description = "XXX domain name",
                    DomainName = props.DnsName,
                });

            new CfnDomainNameApiAssociation(this, "XXX-Domain-Name-Api-Association",
                new CfnDomainNameApiAssociationProps
                {
                    ApiId = graphqlApi.ApiId,
                    DomainName = props.DnsName
                });

            new CnameRecord(this, $"XXX-Domain-Name-CNameRecord", new CnameRecordProps
            {
                RecordName = props.DnsName,
                DomainName = cfnDomainName.AttrAppSyncDomainName,
                Zone = props.HostedZone
            });
        [..]

What did you expect to happen?

AppSync API with a custom domain name and API association would be created.

What actually happened?

XXX |  5/58 | 6:47:13 AM | CREATE_FAILED        | AWS::AppSync::DomainNameApiAssociation | XXX (XXX) Resource handler returned message: "Resource of type 'AWS::AppSync::DomainNameApiAssociation' with identifier 'null' was not found." (RequestToken: 7349ad3a-7dda-4af5-90d9-732ecebe1fbf, HandlerErrorCode: NotFound)

CDK CLI Version

2.7.0

Framework Version

2.7.0

Node.js Version

14.18.3

OS

Debian 10

Language

.NET

Language Version

.net core 3.1

Other information

Observed the same behavior as well with CDK version 1.138.2. Following separation would not show the above error.

    // First stack
        [..]
            var certificate = new DnsValidatedCertificate(this, $"XXX-Api-Certificate",
                new DnsValidatedCertificateProps
                {
                    DomainName = props.DnsName,
                    Region = "us-east-1",
                    HostedZone = props.HostedZone
                });

            var cfnDomainName = new CfnDomainName(this, "XXX-Domain-Name",
                new CfnDomainNameProps
                {
                    CertificateArn = certificate.CertificateArn,
                    Description = "XXX domain name",
                    DomainName = props.DnsName,
                });
        [..]
        
    // Second stack
        [..]
            new CfnDomainNameApiAssociation(this, "XXX-Domain-Name-Api-Association",
                new CfnDomainNameApiAssociationProps
                {
                    ApiId = graphqlApi.ApiId,
                    DomainName = props.DnsName
                });

            new CnameRecord(this, $"XXX-Domain-Name-CNameRecord", new CnameRecordProps
            {
                RecordName = props.DnsName,
                DomainName = cfnDomainName.AttrAppSyncDomainName,
                Zone = props.HostedZone
            });
        [..]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions