-
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (37 loc) · 1.42 KB
/
Copy pathapp.py
File metadata and controls
45 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"""
Example: Access control configuration.
This example demonstrates how to configure access to the webhook and
setup functions using API Gateway with IP restrictions.
"""
import aws_cdk as cdk
from aws_cdk import Stack
from cloudsnorkel.cdk_github_runners import (
GitHubRunners,
CodeBuildRunnerProvider,
LambdaAccess,
)
class AccessControlStack(Stack):
def __init__(self, scope, construct_id, **kwargs):
super().__init__(scope, construct_id, **kwargs)
# Create a CodeBuild provider
codebuild_provider = CodeBuildRunnerProvider(
self, "CodeBuildProvider",
labels=["codebuild", "linux", "x64"]
)
# Create the GitHub runners infrastructure with custom access control
GitHubRunners(
self, "GitHubRunners",
providers=[codebuild_provider],
# Webhook access: Use API Gateway with GitHub webhook IPs
# This is more secure than the default Lambda URL
webhook_access=LambdaAccess.api_gateway(
allowed_ips=LambdaAccess.github_webhook_ips() # Allow GitHub.com webhook IPs
),
# Setup access: Disable after initial setup is complete
# This prevents unauthorized access to the setup function
setup_access=LambdaAccess.no_access()
)
app = cdk.App()
AccessControlStack(app, "access-control-example")
app.synth()