Skip to content

Commit

Permalink
Rename construct and logical id (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
NChitty authored Mar 19, 2024
1 parent 09444a6 commit bd33d90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 34 deletions.
8 changes: 4 additions & 4 deletions cdk/lib/iam/delegation-role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'aws-cdk-lib/aws-iam';
import { ProjectEnvironment } from '../pipeline';

export interface HostedZoneDelegationProps {
export interface HostedZoneDelegateProps {
/**
* The parent hosted zone arn.
*/
Expand All @@ -24,7 +24,7 @@ export interface HostedZoneDelegationProps {
/**
* Wrapper that builds a role to allow delegation of subdomain records to another account.
*/
export class HostedZoneDelegationRole extends Construct {
export class HostedZoneDelegate extends Construct {
readonly defaultAccount: string = '211125587522';
readonly defaultDomain: string = 'mealplanner.projects.chittyinsights.com';

Expand All @@ -36,9 +36,9 @@ export class HostedZoneDelegationRole extends Construct {
*
* @param{Construct} scope the parent scope
* @param{string} id logical id
* @param{HostedZoneDelegationProps} props properties for this role
* @param{HostedZoneDelegateProps} props properties for this role
*/
constructor(scope: Construct, id: string, props: HostedZoneDelegationProps) {
constructor(scope: Construct, id: string, props: HostedZoneDelegateProps) {
super(scope, id);
this.normalizedDomain = this.normalizeRecordName(props.projectEnvironment.subdomain);
this.delegationRole = new Role(this, 'CrossAccountRole', {
Expand Down
27 changes: 1 addition & 26 deletions cdk/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'aws-cdk-lib/pipelines';
import path = require('path');
import { HostedZone } from 'aws-cdk-lib/aws-route53';
import { HostedZoneDelegationRole } from './iam/delegation-role';
import { HostedZoneDelegate } from './iam/delegation-role';

export interface ProjectEnvironment extends Environment {
/**
Expand Down Expand Up @@ -54,12 +54,6 @@ export default class PipelineStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

const projectsHostedZone = HostedZone.fromHostedZoneId(
this,
'ProjectsHostedZone',
'Z09758583PVMFV16WNRXR',
);

const synth = new ShellStep('Synth', {
/* eslint-disable max-len */
input: CodePipelineSource.connection('NChitty/meal-planner', 'main', {
Expand All @@ -80,25 +74,6 @@ export default class PipelineStack extends Stack {
crossAccountKeys: true,
});

const stagingRoleWrapper = new HostedZoneDelegationRole(
this,
`${stagingEnvironment.name}HostedZoneDelegationRole`,
{
hostedZoneArn: projectsHostedZone.hostedZoneArn,
projectEnvironment: stagingEnvironment,
});

projectsHostedZone.grantDelegation(stagingRoleWrapper.delegationRole);

const prodRoleWrapper = new HostedZoneDelegationRole(
this,
`${prodEnvironment.name}HostedZoneDelegationRole`,
{
hostedZoneArn: projectsHostedZone.hostedZoneArn,
projectEnvironment: stagingEnvironment,
});
projectsHostedZone.grantDelegation(prodRoleWrapper.delegationRole);

const stagingStage = new MealPlannerStage(this, 'MealPlannerAppStaging', {
env: stagingEnvironment,
});
Expand Down
8 changes: 4 additions & 4 deletions cdk/lib/shared.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stack, StackProps } from 'aws-cdk-lib';
import { HostedZone } from 'aws-cdk-lib/aws-route53';
import { Construct } from 'constructs';
import { HostedZoneDelegationRole } from './iam/delegation-role';
import { HostedZoneDelegate } from './iam/delegation-role';
import { ProjectEnvironment } from './pipeline';

export interface SharedStackProps extends StackProps {
Expand All @@ -15,7 +15,7 @@ export interface SharedStackProps extends StackProps {
*/
export class SharedStack extends Stack {
public readonly hostedZoneId: string;
public readonly roleWrapper: HostedZoneDelegationRole;
public readonly roleWrapper: HostedZoneDelegate;
/**
* Build the stack resources.
* @param{Construct} scope parent
Expand All @@ -32,9 +32,9 @@ export class SharedStack extends Stack {
);
this.hostedZoneId = projectsHostedZone.hostedZoneId;

this.roleWrapper = new HostedZoneDelegationRole(
this.roleWrapper = new HostedZoneDelegate(
this,
`${props.environment.name}HostedZoneDelegation`,
`${props.environment.name}HostedZoneDelegate`,
{
hostedZoneArn: projectsHostedZone.hostedZoneArn,
projectEnvironment: props.environment,
Expand Down

0 comments on commit bd33d90

Please sign in to comment.