Skip to content

Commit

Permalink
making ipam props private
Browse files Browse the repository at this point in the history
  • Loading branch information
shikha372 committed Aug 6, 2024
1 parent 24d2c15 commit a3d77e6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
9 changes: 2 additions & 7 deletions packages/@aws-cdk/aws-vpcv2-alpha/lib/ipam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export interface IIpamPool{
* IPAM scope is the highest-level container within IPAM. An IPAM contains two default scopes.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipamscope.html
*/
export interface IpamScopeProps extends IpamScopeOptions{
interface IpamScopeProps extends IpamScopeOptions{
/**
* IPAM id to which scope needs to be added
*/
Expand Down Expand Up @@ -267,11 +267,6 @@ export interface IIpamScopeBase{
*/
readonly scopeId: string;

/**
* Properties to configure IPAMScope
*/
readonly props?: IpamScopeProps;

/**
* Defines scope type can be either default or custom
*/
Expand Down Expand Up @@ -370,7 +365,7 @@ class IpamScope extends Resource implements IIpamScopeBase {
/**
* Properties to configure ipam scope
*/
public readonly props: IpamScopeProps;
private readonly props: IpamScopeProps;

/**
* Reference to stack scope to be passed through addPool method inorder to create a new IpamPool
Expand Down
15 changes: 12 additions & 3 deletions packages/@aws-cdk/aws-vpcv2-alpha/lib/vpc-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Construct, DependencyGroup, IDependable } from 'constructs';
import { IpamOptions, IIpamPool } from './ipam';
import { VpcV2Base } from './vpc-v2-base';
import { md5hash } from 'aws-cdk-lib/core/lib/helpers-internal';

/**
* IpAddress options to define VPC V2
*/
Expand Down Expand Up @@ -292,10 +291,10 @@ export class VpcV2 extends VpcV2Base {

let ipCount = 0;
for (const secondaryAddressBlock of secondaryAddressBlocks) {

//Counter to generate a random string for input to hash function
ipCount+=1;
const hash = pathHash('Secondary'+ipCount);

const secondaryVpcOptions: VpcCidrOptions = secondaryAddressBlock.allocateVpcCidr();

if (secondaryVpcOptions.amazonProvided || secondaryVpcOptions.ipv6IpamPool) {
Expand Down Expand Up @@ -475,4 +474,14 @@ function validateIpv4address(cidr1?: string, cidr2?: string): boolean {
function pathHash(path: string): string {
const md5 = md5hash(path);
return md5.slice(0, 4).toUpperCase();
}
}

// function generateRandomString(length: number): string {
// const pattern = /[a-zA-Z0-9]/;
// const characters = pattern.source.replace(/\\/g, '');;
// let result = '';
// for (let i = 0; i < length; i++) {
// result += characters.charAt(Math.floor(Math.random() * characters.length));
// }
// return result;
// }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-vpcv2-alpha/test/vpc-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Template } from 'aws-cdk-lib/assertions';
import * as cdk from 'aws-cdk-lib';
import * as vpc from '../lib/vpc-v2';
import { AddressFamily, AwsServiceName, Ipam, IpamPoolPublicIpSource } from '../lib';

describe('Vpc V2 with full control', () => {
let stack: cdk.Stack;

Expand Down

0 comments on commit a3d77e6

Please sign in to comment.