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

Amplify Gen2 function missing Vpc property #1112

Open
nikhil123987 opened this issue Mar 7, 2024 · 1 comment
Open

Amplify Gen2 function missing Vpc property #1112

nikhil123987 opened this issue Mar 7, 2024 · 1 comment
Assignees
Labels
feature-request New feature or request function Issue pertaining to Amplify Function needs-product-input Needs non-technical requirements or direction to proceed

Comments

@nikhil123987
Copy link

nikhil123987 commented Mar 7, 2024

Environment information

export type FunctionProps = {
    /**
     * A name for the function.
     * Defaults to the basename of the entry path if specified.
     * If no entry is specified, defaults to the directory name in which this function is defined.
     *
     * Example:
     * If entry is `./scheduled-db-backup.ts` the name will default to "scheduled-db-backup"
     * If entry is not set and the function is defined in `amplify/functions/db-backup/resource.ts` the name will default to "db-backup"
     */
    name?: string;
    /**
     * The path to the file that contains the function entry point.
     * If this is a relative path, it is computed relative to the file where this function is defined
     *
     * Defaults to './handler.ts'
     */
    entry?: string;
    /**
     * An amount of time in seconds between 1 second and 15 minutes.
     * Must be a whole number.
     * Default is 3 seconds.
     */
    timeoutSeconds?: number;
    /**
     * An amount of memory (RAM) to allocate to the function between 128 and 10240 MB.
     * Must be a whole number.
     * Default is 128MB.
     */
    memoryMB?: number;
    /**
     * Environment variables that will be available during function execution
     */
    environment?: Record<string, string | BackendSecret>;
    /**
     * Node runtime version for the lambda environment.
     *
     * Defaults to the oldest NodeJS LTS version. See https://nodejs.org/en/about/previous-releases
     */
    runtime?: NodeVersion;
};

Description

Lambda function created using Amplify Gen2 do not have Vpc property just like other props such as timeoutSeconds, environment, memoryMB etc. defineFunction which is imported from @aws-amplify/backend module do not consists of Vpc configurations

Due to missing Vpc property, it is not possible to configure lambda function with VPC.

Workaround : Tried to override the lambda function resource by importing ec2.Vpc.fromVpcAttributes from 'aws-cdk-lib/aws-ec2', however It is not possible to override the lambda function as amplify expects the lambda function to be passed inside defineBackend. The below code snippet do not work :

const backend = defineBackend({});

const functionStack = backend.createStack('functionStack');

const myVPC = ec2.Vpc.fromVpcAttributes(functionStack, 'Gen2Vpc',{
  vpcId: 'vpc-1234',
  availabilityZones: ['eu-central-1a', 'eu-central-1b'],
});

const lambda = new NodejsFunction(functionStack, 'myLambda', {
  // ... other props, 
  vpc: myVPC
});
@nikhil123987 nikhil123987 added the pending-triage Incoming issues that need categorization label Mar 7, 2024
@ykethan
Copy link
Member

ykethan commented Mar 7, 2024

Hey @nikhil123987, thank you for reaching out. Marking this as feature-request.

@ykethan ykethan added feature-request New feature or request function Issue pertaining to Amplify Function and removed pending-triage Incoming issues that need categorization labels Mar 7, 2024
@josefaidt josefaidt added needs-product-input Needs non-technical requirements or direction to proceed p4 labels Mar 19, 2024
@ykethan ykethan removed the p4 label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request function Issue pertaining to Amplify Function needs-product-input Needs non-technical requirements or direction to proceed
Projects
None yet
Development

No branches or pull requests

3 participants