Skip to content

Commit

Permalink
feat: namespace all the types/interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
pgollucci committed Nov 27, 2024
1 parent e5112d8 commit 03abcfe
Show file tree
Hide file tree
Showing 27 changed files with 119 additions and 100 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
"apigwi",
"Brotli",
"configservice",
"delegators",
"eice",
"fieldname",
"GKEJ",
"idmg",
"kqxq",
"lambdajs",
Expand All @@ -72,6 +74,7 @@
"PCIDSS",
"presign",
"presigner",
"SDLC"
"SDLC",
"TMCK"
]
}
4 changes: 2 additions & 2 deletions src/constructs/p6-lz-sra-central-bucket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IPrincipal } from 'aws-cdk-lib/aws-iam'
import type { Construct } from 'constructs'
import type { IShareWithOrg } from '../types'
import type { IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import * as iam from 'aws-cdk-lib/aws-iam'
import * as kms from 'aws-cdk-lib/aws-kms'
Expand Down Expand Up @@ -30,7 +30,7 @@ import { getCentralBucketName } from '../util'
*
*/

export interface IP6LzSraCentralBucketProps extends IShareWithOrg {}
export interface IP6LzSraCentralBucketProps extends IP6LzShareWithOrg {}

export class P6LzSraCentralBucket extends cdk.Resource {
constructor(scope: Construct, id: string, props: IP6LzSraCentralBucketProps) {
Expand Down
4 changes: 2 additions & 2 deletions src/constructs/p6-lz-sra-cloudwatch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Construct } from 'constructs'
import type { IAccountAlias } from '../types'
import type { IP6LzAccountAlias } from '../types'
import * as cdk from 'aws-cdk-lib'
import * as iam from 'aws-cdk-lib/aws-iam'
import * as kms from 'aws-cdk-lib/aws-kms'
import * as logs from 'aws-cdk-lib/aws-logs'

export interface IP6LzSraCloudWatchProps extends IAccountAlias {}
export interface IP6LzSraCloudWatchProps extends IP6LzAccountAlias {}

export class P6LzSraCloudWatch extends cdk.Resource {
public readonly logGroup: logs.ILogGroup
Expand Down
4 changes: 2 additions & 2 deletions src/constructs/p6-lz-sra-config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Construct } from 'constructs'
import type { ILogarchiveBucket, IShareWithOrg } from '../types'
import type { IP6LzLogarchiveBucket, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import * as config from 'aws-cdk-lib/aws-config'
import * as iam from 'aws-cdk-lib/aws-iam'
import * as kms from 'aws-cdk-lib/aws-kms'

export interface IP6LzSraConfigProps extends IShareWithOrg, ILogarchiveBucket {
export interface IP6LzSraConfigProps extends IP6LzShareWithOrg, IP6LzLogarchiveBucket {
// @default false
isCentral?: boolean
}
Expand Down
4 changes: 2 additions & 2 deletions src/constructs/p6-lz-sra-inspector.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountIds, IShareWithOrg } from '../types'
import type { IP6LzAccountIds, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from 'aws-cdk-lib/custom-resources'

export interface IP6LzSraInspectorProps extends cdk.StackProps, IAccountIds, IShareWithOrg {}
export interface IP6LzSraInspectorProps extends cdk.StackProps, IP6LzAccountIds, IP6LzShareWithOrg {}

export class P6LzSraInspector extends cdk.Resource {
constructor(scope: Construct, id: string, props: IP6LzSraInspectorProps) {
Expand Down
4 changes: 2 additions & 2 deletions src/constructs/p6-lz-sra-org-trail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as logs from 'aws-cdk-lib/aws-logs'
import type { Construct } from 'constructs'
import type { ILogarchiveBucket } from '../types'
import type { IP6LzLogarchiveBucket } from '../types'
import * as cdk from 'aws-cdk-lib'
import * as cloudtrail from 'aws-cdk-lib/aws-cloudtrail'
import * as iam from 'aws-cdk-lib/aws-iam'
Expand Down Expand Up @@ -29,7 +29,7 @@ import * as kms from 'aws-cdk-lib/aws-kms'
*
*/

export interface IP6LzSraOrgTrailProps extends ILogarchiveBucket {
export interface IP6LzSraOrgTrailProps extends IP6LzLogarchiveBucket {
logGroup: logs.ILogGroup
logRole: iam.IRole
}
Expand Down
4 changes: 2 additions & 2 deletions src/constructs/p6-lz-vpc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IVpc } from '../types'
import type { IP6LzVpc } from '../types'
import * as cdk from 'aws-cdk-lib'
import * as ec2 from 'aws-cdk-lib/aws-ec2'

export interface IP6LzVpcProps extends cdk.StackProps, IVpc {}
export interface IP6LzVpcProps extends cdk.StackProps, IP6LzVpc {}

export class P6LzVpc extends cdk.Resource {
constructor(scope: Construct, id: string, props: IP6LzVpcProps) {
Expand Down
10 changes: 5 additions & 5 deletions src/resources/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DescribeCreateAccountStatusResponse, ListAccountsCommandOutput, ListOrganizationalUnitsForParentCommandOutput, ListParentsCommandOutput, ListRootsCommandOutput, OrganizationsClient } from '@aws-sdk/client-organizations'
import type { GetObjectCommandOutput, S3Client } from '@aws-sdk/client-s3'
import type { Readable } from 'node:stream'
import type { ExtendedAccounts, IAccountsConfig, MyOrganizationalUnits } from '../types'
import type { IP6LzAccounts, IP6LzAccountsConfig, MyOrganizationalUnits } from '../types'
import { DescribeCreateAccountStatusCommand, ListAccountsCommand, ListOrganizationalUnitsForParentCommand, ListParentsCommand, ListRootsCommand } from '@aws-sdk/client-organizations'
import { GetObjectCommand } from '@aws-sdk/client-s3'
import * as yaml from 'js-yaml'
Expand All @@ -13,7 +13,7 @@ export async function getOuTree(logger: winston.Logger, client: S3Client, ouFile
return ouData
}

export async function getAccounts(logger: winston.Logger, client: S3Client, accountsFileBucket: string, accountsFileKey: string): Promise<ExtendedAccounts> {
export async function getAccounts(logger: winston.Logger, client: S3Client, accountsFileBucket: string, accountsFileKey: string): Promise<IP6LzAccounts> {
const s3Object = await getAccountsFile(logger, client, accountsFileBucket, accountsFileKey)
const accountsData = await parseAccounts(logger, s3Object)
return accountsData
Expand Down Expand Up @@ -255,11 +255,11 @@ async function getAccountsFile(logger: winston.Logger, client: S3Client, account
return s3Object
}

async function parseAccounts(logger: winston.Logger, s3Object: GetObjectCommandOutput): Promise<ExtendedAccounts> {
let accountData: ExtendedAccounts
async function parseAccounts(logger: winston.Logger, s3Object: GetObjectCommandOutput): Promise<IP6LzAccounts> {
let accountData: IP6LzAccounts
try {
const bodyString = await streamToString(s3Object.Body as Readable)
const accountsConfig = yaml.load(bodyString) as IAccountsConfig
const accountsConfig = yaml.load(bodyString) as IP6LzAccountsConfig
accountData = Object.values(accountsConfig.accounts)
logger.info(`Parsed ${accountData.length} accounts from the file`)
}
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/audit-1.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IShareWithOrg } from '../types'
import type { IP6LzAccountAlias, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
import { P6LzSraCloudWatch } from '../constructs/p6-lz-sra-cloudwatch'
import { P6LzSraOrgTrail } from '../constructs/p6-lz-sra-org-trail'
import { getCentralBucket } from '../util'

interface AuditAccountStack1Props extends cdk.StackProps, IAccountAlias, IShareWithOrg {}
interface AuditAccountStack1Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzShareWithOrg {}

export class AuditAccountStack1 extends cdk.Stack {
constructor(scope: Construct, id: string, props: AuditAccountStack1Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/audit-2.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Construct } from 'constructs'
import type { IAccountIds, IShareWithOrg } from '../types'
import type { IP6LzAccountIds, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6LzSraChatbot } from '../constructs/p6-lz-sra-chatbot'
import { P6LzSraConfig } from '../constructs/p6-lz-sra-config'
import { P6LzSraInspector } from '../constructs/p6-lz-sra-inspector'
import { P6LzSraSecurityhub } from '../constructs/p6-lz-sra-security-hub'
import { getCentralBucket } from '../util'

interface AuditAccountStack2Props extends cdk.StackProps, IShareWithOrg, IAccountIds {}
interface AuditAccountStack2Props extends cdk.StackProps, IP6LzShareWithOrg, IP6LzAccountIds {}

export class AuditAccountStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: AuditAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/dev.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IVpc } from '../types'
import type { IP6LzAccountAlias, IP6LzVpc } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
import { P6LzVpc } from '../constructs/p6-lz-vpc'

interface DevAccountStack2Props extends cdk.StackProps, IAccountAlias, IVpc {}
interface DevAccountStack2Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzVpc {}

export class DevAccountStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: DevAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/logarchive-1.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IShareWithOrg } from '../types'
import type { IP6LzAccountAlias, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
import { P6LzSraCentralBucket } from '../constructs/p6-lz-sra-central-bucket'

interface LogarchiveAccountStack1Props extends cdk.StackProps, IAccountAlias, IShareWithOrg {}
interface LogarchiveAccountStack1Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzShareWithOrg {}

export class LogarchiveAccountStack1 extends cdk.Stack {
constructor(scope: Construct, id: string, props: LogarchiveAccountStack1Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/logarchive-2.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IShareWithOrg } from '../types'
import type { IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6LzSraConfig } from '../constructs/p6-lz-sra-config'
import { getCentralBucket } from '../util'

interface LogarchiveAccountStack2Props extends cdk.StackProps, IShareWithOrg {}
interface LogarchiveAccountStack2Props extends cdk.StackProps, IP6LzShareWithOrg {}

export class LogarchiveAccountStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: LogarchiveAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/management-1-organization.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IAccountAlias } from '../types'
import type { IP6LzAccountAlias } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
// import { CfnOrganization } from 'aws-cdk-lib/aws-organizations'

interface OrganizationStackProps extends cdk.StackProps, IAccountAlias {}
interface OrganizationStackProps extends cdk.StackProps, IP6LzAccountAlias {}

export class OrganizationStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: OrganizationStackProps) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/management-2-cloudtrail.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountIds } from '../types'
import type { IP6LzAccountIds } from '../types'
import * as cdk from 'aws-cdk-lib'
import { CloudTrailDelegatedAdmin } from '../constructs/p6-lz-delegators'

interface ManagementAccountCloudTrailStack2Props extends cdk.StackProps, IAccountIds {}
interface ManagementAccountCloudTrailStack2Props extends cdk.StackProps, IP6LzAccountIds {}

export class ManagementAccountCloudTrailStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: ManagementAccountCloudTrailStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/management-2-config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountIds } from '../types'
import type { IP6LzAccountIds } from '../types'
import * as cdk from 'aws-cdk-lib'
import { ConfigDelegatedAdmin } from '../constructs/p6-lz-delegators'

interface ManagementAccountConfigStack2Props extends cdk.StackProps, IAccountIds {}
interface ManagementAccountConfigStack2Props extends cdk.StackProps, IP6LzAccountIds {}

export class ManagementAccountConfigStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: ManagementAccountConfigStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/management-2-inspector.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountIds } from '../types'
import type { IP6LzAccountIds } from '../types'
import * as cdk from 'aws-cdk-lib'
import { InspectorDelegatedAdmin } from '../constructs/p6-lz-delegators'

interface ManagementAccountInspectorStack2Props extends cdk.StackProps, IAccountIds {}
interface ManagementAccountInspectorStack2Props extends cdk.StackProps, IP6LzAccountIds {}

export class ManagementAccountInspectorStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: ManagementAccountInspectorStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/management-2-securityhub.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountIds } from '../types'
import type { IP6LzAccountIds } from '../types'
import * as cdk from 'aws-cdk-lib'
import { SecurityHubDelegatedAdmin } from '../constructs/p6-lz-delegators'

interface ManagementAccountSecurityHubStack2Props extends cdk.StackProps, IAccountIds {}
interface ManagementAccountSecurityHubStack2Props extends cdk.StackProps, IP6LzAccountIds {}

export class ManagementAccountSecurityHubStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: ManagementAccountSecurityHubStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/network-1.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IShareWithOrg } from '../types'
import type { IP6LzAccountAlias, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'

interface NetworkAccountStack1Props extends cdk.StackProps, IAccountAlias, IShareWithOrg {}
interface NetworkAccountStack1Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzShareWithOrg {}

export class NetworkAccountStack1 extends cdk.Stack {
constructor(scope: Construct, id: string, props: NetworkAccountStack1Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/network-2.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IShareWithOrg } from './../types'
import type { IP6LzShareWithOrg } from './../types'
import * as cdk from 'aws-cdk-lib'
import { P6LzSraConfig } from '../constructs/p6-lz-sra-config'
import { getCentralBucket } from '../util'

interface NetworkAccountStack2Props extends cdk.StackProps, IShareWithOrg {}
interface NetworkAccountStack2Props extends cdk.StackProps, IP6LzShareWithOrg {}

export class NetworkAccountStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: NetworkAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/prod.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IVpc } from '../types'
import type { IP6LzAccountAlias, IP6LzVpc } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
import { P6LzVpc } from '../constructs/p6-lz-vpc'

interface ProdAccountStack2Props extends cdk.StackProps, IAccountAlias, IVpc {}
interface ProdAccountStack2Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzVpc {}

export class ProdAccountStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: ProdAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/qa.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IVpc } from '../types'
import type { IP6LzAccountAlias, IP6LzVpc } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
import { P6LzVpc } from '../constructs/p6-lz-vpc'

interface QaAccountStack2Props extends cdk.StackProps, IAccountAlias, IVpc {}
interface QaAccountStack2Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzVpc {}

export class QaAccountStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: QaAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IVpc } from '../types'
import type { IP6LzAccountAlias, IP6LzVpc } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'
import { P6LzVpc } from '../constructs/p6-lz-vpc'

interface SandboxAccountStack2Props extends cdk.StackProps, IAccountAlias, IVpc {}
interface SandboxAccountStack2Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzVpc {}

export class SandboxAccountStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: SandboxAccountStack2Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/shared-1.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Construct } from 'constructs'
import type { IAccountAlias, IShareWithOrg } from '../types'
import type { IP6LzAccountAlias, IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6CDKNamer } from 'p6-cdk-namer'

interface SharedAccountStack1Props extends cdk.StackProps, IAccountAlias, IShareWithOrg {}
interface SharedAccountStack1Props extends cdk.StackProps, IP6LzAccountAlias, IP6LzShareWithOrg {}

export class SharedAccountStack1 extends cdk.Stack {
constructor(scope: Construct, id: string, props: SharedAccountStack1Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/stacks/shared-2.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Construct } from 'constructs'
import type { IShareWithOrg } from '../types'
import type { IP6LzShareWithOrg } from '../types'
import * as cdk from 'aws-cdk-lib'
import { P6LzSraConfig } from '../constructs/p6-lz-sra-config'
import { getCentralBucket } from '../util'

interface SharedAccountStack2Props extends cdk.StackProps, IShareWithOrg {}
interface SharedAccountStack2Props extends cdk.StackProps, IP6LzShareWithOrg {}

export class SharedAccountStack2 extends cdk.Stack {
constructor(scope: Construct, id: string, props: SharedAccountStack2Props) {
Expand Down
Loading

0 comments on commit 03abcfe

Please sign in to comment.