Skip to content
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

fix(aws-certificatemanager): no unused props for DnsValidatedCertificate #22809

Closed
wants to merge 1 commit into from
Closed
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
47 changes: 47 additions & 0 deletions packages/@aws-cdk/aws-certificatemanager/lib/certificate-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@ import { Statistic } from '@aws-cdk/aws-cloudwatch';
import { Duration, Resource } from '@aws-cdk/core';
import { ICertificate } from './certificate';

/**
* Shared properties for certificates
*
* @internal
*/
export interface BaseCertificateProps {
Copy link
Contributor Author

@plumdog plumdog Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: should this be CertificateBaseProps? And does it belong in this file, or in certificate.ts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CertificateBaseProps. certificate-base.ts

/**
* Fully-qualified domain name to request a certificate for.
*
* May contain wildcards, such as ``*.domain.com``.
*/
readonly domainName: string;

/**
* Alternative domain names on your certificate.
*
* Use this to register alternative domain names that represent the same site.
*
* @default - No additional FQDNs will be included as alternative domain names.
*/
readonly subjectAlternativeNames?: string[];

/**
* Enable or disable transparency logging for this certificate
*
* Once a certificate has been logged, it cannot be removed from the log.
* Opting out at that point will have no effect. If you opt out of logging
* when you request a certificate and then choose later to opt back in,
* your certificate will not be logged until it is renewed.
* If you want the certificate to be logged immediately, we recommend that you issue a new one.
*
* @see https://docs.aws.amazon.com/acm/latest/userguide/acm-bestpractices.html#best-practices-transparency
*
* @default true
*/
readonly transparencyLoggingEnabled?: boolean;

/**
* The Certifcate name.
*
* Since the Certifcate resource doesn't support providing a physical name, the value provided here will be recorded in the `Name` tag
*
* @default the full, absolute path of this construct
*/
readonly certificateName?: string
}

/**
* Shared implementation details of ICertificate implementations.
*
Expand Down
44 changes: 2 additions & 42 deletions packages/@aws-cdk/aws-certificatemanager/lib/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as route53 from '@aws-cdk/aws-route53';
import { IResource, Token, Tags } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CertificateBase } from './certificate-base';
import { CertificateBase, BaseCertificateProps } from './certificate-base';
import { CfnCertificate } from './certificatemanager.generated';
import { apexDomain } from './util';

Expand Down Expand Up @@ -36,23 +36,7 @@ export interface ICertificate extends IResource {
/**
* Properties for your certificate
*/
export interface CertificateProps {
/**
* Fully-qualified domain name to request a certificate for.
*
* May contain wildcards, such as ``*.domain.com``.
*/
readonly domainName: string;

/**
* Alternative domain names on your certificate.
*
* Use this to register alternative domain names that represent the same site.
*
* @default - No additional FQDNs will be included as alternative domain names.
*/
readonly subjectAlternativeNames?: string[];

export interface CertificateProps extends BaseCertificateProps {
/**
* What validation domain to use for every requested domain.
*
Expand All @@ -77,30 +61,6 @@ export interface CertificateProps {
* @default CertificateValidation.fromEmail()
*/
readonly validation?: CertificateValidation;

/**
* Enable or disable transparency logging for this certificate
*
* Once a certificate has been logged, it cannot be removed from the log.
* Opting out at that point will have no effect. If you opt out of logging
* when you request a certificate and then choose later to opt back in,
* your certificate will not be logged until it is renewed.
* If you want the certificate to be logged immediately, we recommend that you issue a new one.
*
* @see https://docs.aws.amazon.com/acm/latest/userguide/acm-bestpractices.html#best-practices-transparency
*
* @default true
*/
readonly transparencyLoggingEnabled?: boolean;

/**
* The Certifcate name.
*
* Since the Certifcate resource doesn't support providing a physical name, the value provided here will be recorded in the `Name` tag
*
* @default the full, absolute path of this construct
*/
readonly certificateName?: string
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import * as lambda from '@aws-cdk/aws-lambda';
import * as route53 from '@aws-cdk/aws-route53';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CertificateProps, ICertificate } from './certificate';
import { CertificateBase } from './certificate-base';
import { ICertificate } from './certificate';
import { CertificateBase, BaseCertificateProps } from './certificate-base';

/**
* Properties to create a DNS validated certificate managed by AWS Certificate Manager
*
*/
export interface DnsValidatedCertificateProps extends CertificateProps {
export interface DnsValidatedCertificateProps extends BaseCertificateProps {
/**
* Route 53 Hosted Zone used to perform DNS validation of the request. The zone
* must be authoritative for the domain name specified in the Certificate Request.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PublicHostedZone } from '@aws-cdk/aws-route53';
import { App, Stack, RemovalPolicy, CfnOutput, Fn } from '@aws-cdk/core';
import { IntegTest } from '@aws-cdk/integ-tests';
import { DnsValidatedCertificate, CertificateValidation } from '../lib';
import { DnsValidatedCertificate } from '../lib';

/**
* In order to test this you need to have a valid public hosted zone that you can use
Expand Down Expand Up @@ -36,7 +36,6 @@ const hostedZone = PublicHostedZone.fromHostedZoneAttributes(stack, 'HostedZone'
const cert = new DnsValidatedCertificate(stack, 'Certificate', {
domainName,
hostedZone,
validation: CertificateValidation.fromDns(hostedZone),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This certainly feels like it should be redundant (as the fromDns is covered by virtue of being a DnsValidateCertificate, and the hostedZone is passed as its own prop). And couldn't see it getting used in dns-validated-certificate.ts anywhere.

});
cert.applyRemovalPolicy(RemovalPolicy.RETAIN);
new CfnOutput(stack, 'CertificateArn', {
Expand Down