Code Monkey home page Code Monkey logo

aws-cdk-eks-lambda-proxy-workaround's Introduction

aws-cdk-eks-lambda-proxy-workaround

UPDATE: The fix has been released. This workaround is no longer necessary.

Workaround for proxy support in the onEvent EKS Lambda. This workaround is necessary until this fix is released.

Before you continue

This workaround involves replacing the EKS's "onEventHandler" Lambda function through the AWS Console.

This workaround expects that you have already deployed the EKS cluster using "aws-cdk": "1.125.0" or below.

This workaround expects that you have configured your cluster for proxy support.

e.g.

import { Cluster, KubernetesVersion } from '@aws-cdk/aws-eks';
import { Port } from '@aws-cdk/aws-ec2';

...

const cluster = new Cluster(stack, 'hello-eks', {
  vpc,
  version: KubernetesVersion.V1_21,
  placeClusterHandlerInVpc: true,
  clusterHandlerEnvironment: {
    http_proxy: `http://${USERNAME}:${PASSWORD}@${proxyInstance.instancePublicIp}:3128`, // Set the http_proxy environment variable to the proxy server's URL
  },
});
cluster.connections.allowTo(proxyInstance, Port.tcp(80), 'Allow HTTP traffic to the proxy server');

Steps

1. Clone this repo and step in

$ git clone https://github.com/ryparker/aws-cdk-eks-lambda-proxy-workaround.git
$ cd aws-cdk-eks-lambda-proxy-workaround.git

2. Run the bundle script to build the Docker image and output a handler.zip file.

Docker daemon must be running

$ ./bundle.sh

3. Locate the EKS's "onEventHandler" Lambda function in the AWS Console

The "onEventHandler" Lambda will have the following:

  • Function name: <STACK_NAME>-OnEventHandler<HASH>-<HASH>
  • Description: onEvent handler for EKS cluster resource provider



4. Click Upload from and select .zip file




5. Upload the handler.zip we created in step 2. Then click save




6. Confirm the upload was successful

  • A node_modules directory is present.
  • The common.js file now configures the proxy agent.
  • "Changes deployed" status appears at the top of the editor.



All aws-sdk-js requests in the Lambda should now be routed through a proxy. Once the official fix is released this Lambda will be overwritten on the next cdk deploy.

For details on the issue and official fix see this PR

aws-cdk-eks-lambda-proxy-workaround's People

Contributors

ryparker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.