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

chore(efs): drop Efs prefix from all exported types #7481

Merged
merged 6 commits into from
Apr 23, 2020
Merged
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
87 changes: 32 additions & 55 deletions packages/@aws-cdk/aws-efs/lib/efs-file-system.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as kms from '@aws-cdk/aws-kms';
import {Construct, Resource, Tag} from '@aws-cdk/core';
import {CfnFileSystem, CfnMountTarget} from './efs.generated';
import { Construct, IResource, Resource, Size, Tag } from '@aws-cdk/core';
import { CfnFileSystem, CfnMountTarget } from './efs.generated';

// tslint:disable: max-line-length
// tslint:disable:max-line-length
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. link 2 lines below exceeds our 150 line width.

/**
* EFS Lifecycle Policy, if a file is not accessed for given days, it will move to EFS Infrequent Access.
*
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html#cfn-elasticfilesystem-filesystem-lifecyclepolicies
*/
export enum EfsLifecyclePolicyProperty {
// tslint:enable
export enum LifecyclePolicy {
/**
* After 7 days of not being accessed.
*/
Expand Down Expand Up @@ -41,7 +42,7 @@ export enum EfsLifecyclePolicyProperty {
*
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html#cfn-efs-filesystem-performancemode
*/
export enum EfsPerformanceMode {
export enum PerformanceMode {
/**
* This is the general purpose performance mode for most file systems.
*/
Expand All @@ -59,7 +60,7 @@ export enum EfsPerformanceMode {
*
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html#cfn-elasticfilesystem-filesystem-throughputmode
*/
export enum EfsThroughputMode {
export enum ThroughputMode {
/**
* This mode on Amazon EFS scales as the size of the file system in the standard storage class grows.
*/
Expand All @@ -74,7 +75,7 @@ export enum EfsThroughputMode {
/**
* Interface to implement AWS File Systems.
*/
export interface IEfsFileSystem extends ec2.IConnectable {
export interface IFileSystem extends ec2.IConnectable, IResource {
/**
* The ID of the file system, assigned by Amazon EFS.
*
Expand All @@ -86,7 +87,7 @@ export interface IEfsFileSystem extends ec2.IConnectable {
/**
* Properties of EFS FileSystem.
*/
export interface EfsFileSystemProps {
export interface FileSystemProps {

/**
* VPC to launch the file system in.
Expand Down Expand Up @@ -133,51 +134,36 @@ export interface EfsFileSystemProps {
*
* @default - none
*/
readonly lifecyclePolicy?: EfsLifecyclePolicyProperty;
readonly lifecyclePolicy?: LifecyclePolicy;

/**
* Enum to mention the performance mode of the file system.
*
* @default - GENERAL_PURPOSE
*/
readonly performanceMode?: EfsPerformanceMode;
readonly performanceMode?: PerformanceMode;

/**
* Enum to mention the throughput mode of the file system.
*
* @default - BURSTING
*/
readonly throughputMode?: EfsThroughputMode;
readonly throughputMode?: ThroughputMode;

/**
* Provisioned throughput for the file system. This is a required property if the throughput mode is set to PROVISIONED.
* Valid values are 1-1024.
* Provisioned throughput for the file system.
* This is a required property if the throughput mode is set to PROVISIONED.
* Must be at least 1MiB/s.
*
* @default - None, errors out
* @default - none, errors out
*/
readonly provisionedThroughputInMibps?: number;
}

/**
* A new or imported EFS File System.
*/
abstract class EfsFileSystemBase extends Resource implements IEfsFileSystem {

/**
* The security groups/rules used to allow network connections to the file system.
*/
public abstract readonly connections: ec2.Connections;

/**
* @attribute
*/
public abstract readonly fileSystemId: string;
readonly provisionedThroughputPerSecond?: Size;
}

/**
* Properties that describe an existing EFS file system.
*/
export interface EfsFileSystemAttributes {
export interface FileSystemAttributes {
/**
* The security group of the file system
*/
Expand All @@ -186,7 +172,7 @@ export interface EfsFileSystemAttributes {
/**
* The File System's ID.
*/
readonly fileSystemID: string;
readonly fileSystemId: string;
}

/**
Expand All @@ -199,17 +185,17 @@ export interface EfsFileSystemAttributes {
*
* @resource AWS::EFS::FileSystem
*/
export class EfsFileSystem extends EfsFileSystemBase {
export class FileSystem extends Resource implements IFileSystem {

/**
* Import an existing File System from the given properties.
*/
public static fromEfsFileSystemAttributes(scope: Construct, id: string, attrs: EfsFileSystemAttributes): IEfsFileSystem {
class Import extends EfsFileSystemBase implements IEfsFileSystem {
public readonly fileSystemId = attrs.fileSystemID;
public static fromFileSystemAttributes(scope: Construct, id: string, attrs: FileSystemAttributes): IFileSystem {
class Import extends Resource implements IFileSystem {
public readonly fileSystemId = attrs.fileSystemId;
public readonly connections = new ec2.Connections({
securityGroups: [attrs.securityGroup],
defaultPort: ec2.Port.tcp(EfsFileSystem.DEFAULT_PORT),
defaultPort: ec2.Port.tcp(FileSystem.DEFAULT_PORT),
});
}

Expand All @@ -231,37 +217,28 @@ export class EfsFileSystem extends EfsFileSystemBase {
*/
public readonly fileSystemId: string;

private readonly efsFileSystem: CfnFileSystem;

/**
* Constructor for creating a new EFS FileSystem.
*/
constructor(scope: Construct, id: string, props: EfsFileSystemProps) {
constructor(scope: Construct, id: string, props: FileSystemProps) {
super(scope, id);

if (props.throughputMode === EfsThroughputMode.PROVISIONED) {
if (props.provisionedThroughputInMibps === undefined) {
throw new Error('Property provisionedThroughputInMibps is required when throughputMode is PROVISIONED');
} else if (!Number.isInteger(props.provisionedThroughputInMibps)) {
throw new Error('Invalid input for provisionedThroughputInMibps');
} else if (props.provisionedThroughputInMibps < 1 || props.provisionedThroughputInMibps > 1024) {
this.node.addWarning('Valid values for throughput are 1-1024 MiB/s. You can get this limit increased by contacting AWS Support.');
}
if (props.throughputMode === ThroughputMode.PROVISIONED && props.provisionedThroughputPerSecond === undefined) {
throw new Error('Property provisionedThroughputPerSecond is required when throughputMode is PROVISIONED');
}

this.efsFileSystem = new CfnFileSystem(this, 'Resource', {
const filesystem = new CfnFileSystem(this, 'Resource', {
encrypted: props.encrypted,
kmsKeyId: (props.kmsKey ? props.kmsKey.keyId : undefined),
lifecyclePolicies: (props.lifecyclePolicy ? Array.of({
transitionToIa: EfsLifecyclePolicyProperty[props.lifecyclePolicy],
transitionToIa: LifecyclePolicy[props.lifecyclePolicy],
} as CfnFileSystem.LifecyclePolicyProperty) : undefined),
performanceMode: props.performanceMode,
throughputMode: props.throughputMode,
provisionedThroughputInMibps: props.provisionedThroughputInMibps,
provisionedThroughputInMibps: props.provisionedThroughputPerSecond?.toMebibytes(),
});

this.fileSystemId = this.efsFileSystem.ref;
this.node.defaultChild = this.efsFileSystem;
this.fileSystemId = filesystem.ref;
Tag.add(this, 'Name', props.fileSystemName || this.node.path);

const securityGroup = (props.securityGroup || new ec2.SecurityGroup(this, 'EfsSecurityGroup', {
Expand All @@ -270,7 +247,7 @@ export class EfsFileSystem extends EfsFileSystemBase {

this.connections = new ec2.Connections({
securityGroups: [securityGroup],
defaultPort: ec2.Port.tcp(EfsFileSystem.DEFAULT_PORT),
defaultPort: ec2.Port.tcp(FileSystem.DEFAULT_PORT),
});

const subnets = props.vpc.selectSubnets(props.vpcSubnets);
Expand Down
8 changes: 0 additions & 8 deletions packages/@aws-cdk/aws-efs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@
"engines": {
"node": ">= 10.12.0"
},
"awslint": {
"exclude": [
"props-physical-name:@aws-cdk/aws-efs.EfsFileSystemProps",
"resource-interface:@aws-cdk/aws-efs.EfsFileSystem",
"construct-interface-extends-iconstruct:@aws-cdk/aws-efs.IEfsFileSystem",
"resource-interface-extends-resource:@aws-cdk/aws-efs.IEfsFileSystem"
]
},
"stability": "experimental",
"maturity": "experimental",
"awscdkio": {
Expand Down
Loading