-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(efs): import access point - fromAccessPointAttributes()
#10712
Conversation
Also update aws-lambda filesystem 'fromEfsAccessPoint' to expect an IAccessPoint instead of AccessPoint
I just looked into it again. I'm not sure it makes sense to me anymore. Also, the issue is still valid, the implementation I made doesn't seem like the right way to do it. If you think the same, I'm happy to discuss about the implementation and close this Pull Request. I'm just confused about the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome first pass!! thanks for getting the ball rolling on this. I have some thoughts that I'd love to work in before merging this in. The most important one is creating a class that represents an imported file system. Take a look at the example of how it's done in rds
and let me know what you think!
Pull request has been modified.
@shivlaks We could extract the existing imported file system class if it's what you mean. I can do the same for the AccessPoint as well. About the IFileSystem property in the IAccessPoint, I made it mandatory because of the lambda efs implementation. This is the only place where the AccessPoint class is used and it needs the FileSystem to be able to setup the ingress rules. So, at the moment, we cannot import an existing access point since it doesn't have the fileSystem property when using Also, I dropped the existing Let me know what you think and I can update the code accordingly. |
yep that is what I mean. extract to
got it, thanks for explaining! might be worth a comment.
It seems reasonable to me. Adding the
I agree, let's avoid dropping the method.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions below.
/** | ||
* The efs filesystem | ||
*/ | ||
readonly fileSystem?: IFileSystem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about make this mandatory and throw an error in the implementation of fromAccessPointId()
?
The error message can be "fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nija-at, that would also be a breaking change as well, right ?
I'm wondering if there is a use-case (outside of EFS for lambda) where we would need to import an AccessPoint without having the need for FileSystem
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
efs is an experimental module. Breaking changes are acceptable as long as they are called out in the commit description.
I'm wondering if there is a use-case (outside of EFS for lambda) where we would need to import an AccessPoint without having the need for FileSystem ?
In such cases exist, the fromAccessPointId()
API can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I didn't get the idea of how to implement this at start. I think I'm good now. I'm doing the same as in the rds imported cluster and throw the exception on the Getter when fileSystem is not present.. See below. Will update the PR.
class ImportedAccessPoint extends AccessPointBase {
public readonly accessPointId: string;
public readonly accessPointArn: string;
private readonly _fileSystem?: IFileSystem;
constructor(scope: Construct, id: string, attrs: AccessPointAttributes) {
super(scope, id);
if (!attrs.accessPointId) {
if (!attrs.accessPointArn) {
throw new Error('One of accessPointId or AccessPointArn is required!');
}
this.accessPointArn = attrs.accessPointArn;
let maybeApId = Stack.of(scope).parseArn(attrs.accessPointArn).resourceName;
if (!maybeApId) {
throw new Error('ARN for AccessPoint must provide the resource name.');
}
this.accessPointId = maybeApId;
} else {
if (attrs.accessPointArn) {
throw new Error('Only one of accessPointId or AccessPointArn can be provided!');
}
this.accessPointId = attrs.accessPointId;
this.accessPointArn = Stack.of(scope).formatArn({
service: 'elasticfilesystem',
resource: 'access-point',
resourceName: attrs.accessPointId,
});
}
this._fileSystem = attrs.fileSystem;
}
public get fileSystem() {
if (!this._fileSystem) {
throw new Error("fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead");
}
return this._fileSystem;
}
}
fromAccessPointAttributes()
fromAccessPointAttributes()
fromAccessPointAttributes()
…System when it doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Cannot use
efs.AccessPoint.fromAccessPointId()
withlambda.FileSystem.fromEfsAccessPoint()
. the former returns anIAccessPoint
when the later expect anAccessPoint
. I think following the CDK guidelines,lambda.FileSystem.fromEfsAccessPoint()
should expect anIAccessPoint
, not anAccessPoint
.Argument of type
IAccessPoint
is not assignable to parameter of typeAccessPoint
.Solution
Add a new import method to the
AccessPoint
class calledfromAccessPointAttributes()
allowing to pass a fileSystem as an attribute.Closes #10711.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license