Skip to content

Commit

Permalink
refactor: Apply new GuAppAwareConstruct to GuCertificate
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Oct 22, 2021
1 parent 188a5e3 commit fb3be1c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/constructs/acm/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HostedZone } from "@aws-cdk/aws-route53";
import { RemovalPolicy } from "@aws-cdk/core";
import { Stage } from "../../constants";
import { GuStatefulMigratableConstruct } from "../../utils/mixin";
import { GuAppAwareConstruct } from "../../utils/mixin/app-aware-construct";
import type { GuStack } from "../core";
import { AppIdentity } from "../core/identity";
import type { GuMigratingResource } from "../core/migrating";
Expand Down Expand Up @@ -58,7 +59,7 @@ export interface GuDnsValidatedCertificateProps {
* });
*```
*/
export class GuCertificate extends GuStatefulMigratableConstruct(Certificate) {
export class GuCertificate extends GuStatefulMigratableConstruct(GuAppAwareConstruct(Certificate)) {
constructor(scope: GuStack, props: GuCertificatePropsWithApp) {
const maybeHostedZone =
props.CODE.hostedZoneId && props.PROD.hostedZoneId
Expand All @@ -71,16 +72,16 @@ export class GuCertificate extends GuStatefulMigratableConstruct(Certificate) {
})
)
: undefined;
const awsCertificateProps: CertificateProps & GuMigratingResource = {
const awsCertificateProps: CertificateProps & GuMigratingResource & AppIdentity = {
domainName: scope.withStageDependentValue({
variableName: "domainName",
stageValues: { [Stage.CODE]: props.CODE.domainName, [Stage.PROD]: props.PROD.domainName },
}),
validation: CertificateValidation.fromDns(maybeHostedZone),
existingLogicalId: props.existingLogicalId,
app: props.app,
};
super(scope, AppIdentity.suffixText({ app: props.app }, "Certificate"), awsCertificateProps);
super(scope, "Certificate", awsCertificateProps);
this.applyRemovalPolicy(RemovalPolicy.RETAIN);
AppIdentity.taggedConstruct({ app: props.app }, this);
}
}

0 comments on commit fb3be1c

Please sign in to comment.