Skip to content

Conversation

Sliiiin
Copy link
Contributor

@Sliiiin Sliiiin commented Aug 29, 2025

Issue #, if available: #2824

Description of changes:

This pattern creates an Amazon Private API Gateway that is only accessible through VPC endpoints, with public custom domain name resolution for internal only access through an Amazon internal Application Load Balancer.

This architecture is intended for:

Internal APIs: APIs that should only be accessible from within your network
Client VPN Access: APIs accessible via AWS Client VPN connections
Hybrid Connectivity: APIs accessible from on-premises via VPN/Direct Connect
Public DNS Resolution: APIs that resolve publicly but are only accessible privately
This is a joint pattern by http://github.com/bquintas and https://github.com/Sliiiin

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Sliiiin Sliiiin force-pushed the nilbrand-feature-private-apigw-public-custom-domain branch from c44c325 to be4bb6c Compare August 29, 2025 09:46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

This architecture is intended for:
- **Internal APIs**: APIs that should only be accessible from within your network
- **Hybrid Connectivity**: APIs accessible from on-premises via VPN/Direct Connect
- **Public DNS Resolution**: APIs that resolve publicly but are only accessible privately
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use-case for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

- **Hybrid Connectivity**: APIs accessible from on-premises via VPN/Direct Connect
- **Public DNS Resolution**: APIs that resolve publicly but are only accessible privately

Learn more about this pattern at Serverless Land Patterns: << Add the live URL here >>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace with the actual url using your folder name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced.

## Troubleshooting

### Certificate Issues
- Ensure certificate is in the same region as deployment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Ensure certificate is in the same region as deployment
- Ensure certificate is in the same region

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.


### Lambda Function Issues
- Check CloudWatch logs for the RegisterVPCEndpointTargets function
- Verify IAM permissions for EC2 and ELB operations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly is necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

Comment on lines 39 to 41
2. **AWS CDK**: Installed and AWS Account bootstrapped
3. **ACM Certificate**: Valid certificate for your domain in the deployment region
4. **AWS CLI**: Configured with appropriate permissions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add relevant links to the documentation. Compare to other submissions for style guide

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links added.


#### Outputs

The stack provides these outputs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these all necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only necessary output remaining.

"elasticloadbalancing:DeregisterTargets",
"elasticloadbalancing:DescribeTargetHealth"
],
resources=["*"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be restricted to the current account and region?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition for region added.

# Lambda function to register VPC endpoint IPs as targets
register_targets_function = _lambda.Function(
self, "RegisterVPCEndpointTargets",
runtime=_lambda.Runtime.PYTHON_3_9,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the most up-to-date version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to PYTHON_3_13

## Security Features

- API only accessible through VPC endpoint
- Security groups restrict access to VPC and Client VPN ranges
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the ALB Security group allowing traffic from anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an internal load balancer: internet_facing=False, this would need to be adapted by users for more fine grained access when VPN is set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants