Skip to content

LambdaAccess Class ​

Access configuration options for Lambda functions like setup and webhook function. Use this to limit access to these functions.

If you need a custom access point, you can implement this abstract class yourself. Note that the Lambda functions expect API Gateway v1 or v2 input. They also expect every URL under the constructed URL to point to the function.

Initializer ​

ts
import { LambdaAccess } from '@cloudsnorkel/cdk-github-runners'

new LambdaAccess()
python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.LambdaAccess()
java
import com.cloudsnorkel.cdk.github.runners.LambdaAccess;

new LambdaAccess();
csharp
using CloudSnorkel;

new LambdaAccess();
go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.NewLambdaAccess() LambdaAccess

Methods ​

bind()bind()bind()Bind()Bind() ​

Creates all required resources and returns access URL or empty string if disabled.

ts
public bind(scope: Construct, id: string, lambdaFunction: Function): string
python
def bind(
  scope: Construct,
  id: str,
  lambda_function: Function
) -> str
java
public java.lang.String bind(Construct scope, java.lang.String id, Function lambdaFunction)
csharp
private string Bind(Construct Scope, string Id, Function LambdaFunction)
go
func Bind(scope Construct, id *string, lambdaFunction Function) *string

Static Functions ​

apiGateway()api_gateway()apiGateway()ApiGateway()ApiGateway() ​

Provide access using API Gateway.

This is the most secure option, but requires additional configuration. It allows you to limit access to specific IP addresses and even to a specific VPC.

To limit access to GitHub.com use:

LambdaAccess.apiGateway({
  allowedIps: LambdaAccess.githubWebhookIps(),
});

Alternatively, get and manually update the list manually with:

curl https://api.github.com/meta | jq .hooks
ts
import { LambdaAccess } from '@cloudsnorkel/cdk-github-runners'

LambdaAccess.apiGateway(props?: ApiGatewayAccessProps)
python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.LambdaAccess.api_gateway(
  access_log_group: ILogGroup = None,
  allowed_ips: typing.List[str] = None,
  allowed_security_groups: typing.List[ISecurityGroup] = None,
  allowed_vpc: IVpc = None,
  allowed_vpc_endpoints: typing.List[IVpcEndpoint] = None,
  logging_level: MethodLoggingLevel = None
)
  • access_log_group?: ILogGroup

    Log group for access logs, with one JSON line for each request.

    API Gateway can only write logs once the account has a CloudWatch Logs role. See https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html

    Default: no access logs

  • allowed_ips?: typing.List[str]

    List of IP addresses in CIDR notation that are allowed to access the API Gateway.

    If not specified on public API Gateway, all IP addresses are allowed.

    If not specified on private API Gateway, no IP addresses are allowed (but specified security groups are).

  • allowed_security_groups?: typing.List[ISecurityGroup]

    List of security groups that are allowed to access the API Gateway.

    Only works for private API Gateways with ApiGatewayAccessProps.allowedVpc.

  • allowed_vpc?: IVpc

    Create a private API Gateway and allow access from the specified VPC.

  • allowed_vpc_endpoints?: typing.List[IVpcEndpoint]

    Create a private API Gateway and allow access from the specified VPC endpoints.

    Use this to make use of existing VPC endpoints or to share an endpoint between multiple functions. The VPC endpoint must point to ec2.InterfaceVpcEndpointAwsService.APIGATEWAY.

    No other settings are supported when using this option.

    All endpoints will be allowed access, but only the first one will be used as the URL by the runner system for setting up the webhook, and as setup URL.

  • logging_level?: MethodLoggingLevel

    Level of execution logs. API Gateway writes them to its own log group named API-Gateway-Execution-Logs_{rest-api-id}/{stage}.

    Like access logs, these need a CloudWatch Logs role in the account.

    Default: no execution logs

java
import com.cloudsnorkel.cdk.github.runners.LambdaAccess;

LambdaAccess.apiGateway(),LambdaAccess.apiGateway(ApiGatewayAccessProps props)
csharp
using CloudSnorkel;

LambdaAccess.ApiGateway(ApiGatewayAccessProps Props = null);
go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.LambdaAccess_ApiGateway(props ApiGatewayAccessProps) LambdaAccess

githubWebhookIps()github_webhook_ips()githubWebhookIps()GithubWebhookIps()GithubWebhookIps() ​

Downloads the list of IP addresses used by GitHub.com for webhooks.

Note that downloading dynamic data during deployment is not recommended in CDK. This is a workaround for the lack of a better solution.

ts
import { LambdaAccess } from '@cloudsnorkel/cdk-github-runners'

LambdaAccess.githubWebhookIps()
python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.LambdaAccess.github_webhook_ips()
java
import com.cloudsnorkel.cdk.github.runners.LambdaAccess;

LambdaAccess.githubWebhookIps()
csharp
using CloudSnorkel;

LambdaAccess.GithubWebhookIps();
go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.LambdaAccess_GithubWebhookIps() *[]*string

lambdaUrl()lambda_url()lambdaUrl()LambdaUrl()LambdaUrl() ​

Provide access using Lambda URL.

This is the default and simplest option. It puts no limits on the requester, but the Lambda functions themselves authenticate every request.

ts
import { LambdaAccess } from '@cloudsnorkel/cdk-github-runners'

LambdaAccess.lambdaUrl()
python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.LambdaAccess.lambda_url()
java
import com.cloudsnorkel.cdk.github.runners.LambdaAccess;

LambdaAccess.lambdaUrl()
csharp
using CloudSnorkel;

LambdaAccess.LambdaUrl();
go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.LambdaAccess_LambdaUrl() LambdaAccess

noAccess()no_access()noAccess()NoAccess()NoAccess() ​

Disables access to the configured Lambda function.

This is useful for the setup function after setup is done.

ts
import { LambdaAccess } from '@cloudsnorkel/cdk-github-runners'

LambdaAccess.noAccess()
python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.LambdaAccess.no_access()
java
import com.cloudsnorkel.cdk.github.runners.LambdaAccess;

LambdaAccess.noAccess()
csharp
using CloudSnorkel;

LambdaAccess.NoAccess();
go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.LambdaAccess_NoAccess() LambdaAccess

Released under the Apache-2.0 License.