Checkpoints
Virtual Private Network between AWS and Google Cloud
/ 25
Create VM instances
/ 25
Setup OAuth Consent
/ 25
Configure on-prem IAP connector
/ 25
Securing Multi-Cloud Applications using BeyondCorp Enterprise (BCE)
GSP1034
Overview
In this lab, you will configure BeyondCorp Enterprise (BCE) to restrict access to an application backends that reside on multiple cloud providers, in this case, GCP and AWS. This can be beneficial for the following use cases which benefit from BCE’s Zero Trust security model:
-
Securing 3rd party cloud provider applications i.e. SFDC, etc.
-
Securing and uniting infrastructure distributed between one or more cloud providers.
-
Securing migration from one cloud provider to another.
-
Simulating on-premise VPN connections.
-
Removing manual route configurations.
What you'll do
In this lab, you will be provided with a Google Cloud Project and an Amazon Web Services account. You will utilize the features of BeyondCorp Enterprise (BCE) to secure applications running on both clouds by:
-
Creating a GCP Cloud Router and VPN Gateway
-
Creating an AWS Customer Gateway, Virtual Private Gateway and Site to Site VPN Connection
-
Configuring the bi-directional VPN tunnels to enable application connectivity
-
Deploy the BeyondCorp Enterprise, Identity Aware Proxy (IAP) On-Prem Connector to protect traffic routed to AWS
Create GCP Cloud Router
- Open the GCP console and go to NETWORKING > Hybrid connectivity > Cloud routers > Create router
Use the following configuration for the cloud router:
-
Name:
cloud-router
-
Network:
default
-
Region:
us-central1(lowa)
-
Google ASN value:
65001
-
Select
Advertise all subnets visible to the Cloud Router
in order to expose your subnets to BGP routing and to AWS router.
- Click Create.
Create GCP Cloud HA VPN gateway
-
Go to NETWORKING > Hybrid connectivity > VPN > Create VPN Connection
-
Select High-availability (HA) VPN then click Continue.
Use the following configuration for the VPN:
-
VPN Gateway Name:
ha-vpn
-
Network:
default
-
Region:
us-central1(lowa)
- Click Create & Continue.
As we don’t have anything configured in the AWS account we can skip the Add VPN Tunnels and Configure BGP sessions for now.
Create the AWS Customer Gateway
-
Open the AWS console and go to VPC > Virtual Private Network (VPN) > Customer Gateways > Create Customer Gateway:
- Name tag:
gcp
- BGP ASN:
65001
- IP address:
Enter the IP address from interface 0 from the "ha-vpn" in the GCP project
You can find the IP address of interface0
in the VPN section of the GCP console for the ha-vpn
created earlier.
- Click Create customer gateway
Create the AWS Virtual private gateway
-
Go to VPC > Virtual Private Network (VPN) > Virtual Private Gateways > Create Virtual Private Gateway:
-
Name tag:
vpn
-
Select
Custom ASN
and set:65002
- Click Create Virtual Private Gateway.
After the Virtual Private gateway has been created, select the Virtual Private gateway and go to actions and Attach to VPC. Then select the Default VPC.
Click Attach to VPC.
Create AWS Site-to-site VPN Connection
-
Go to VPC > Virtual Private Network (VPN) > Site-to-site VPN Connections > Create VPN Connection
-
Name tag:
gcp
-
Target gateway type:
Virtual private gateway
-
Virtual private gateway:
{{Select the virtual private gateway you created previously}}
-
Customer gateway:
Existing
-
Customer gateway ID:
{{Select the customer gateway created previously}}
-
Routing options:
Dynamic
- Leave the default values for the rest of the inputs and click Create VPN connection.
After the Site-to-site VPN connection is created, select the VPN connection and click on the download configuration.
When downloading the configuration, select:
- Vendor:
Cisco Systems, Inc.
- Platform:
ASA 5500 Series
- Software:
ASA 9.7+ VTI
- IKE version:
ikev1
Click Download.
Tunnels Configuration
On the Site-to-site VPN Connections page, click on Tunnel details to view the details. There will be two (2) tunnels with details. We will be using the first tunnel only.
Copy the following values which will be used in your GCP project to create the Peer VPN Gateway, create a VPN tunnel and configure BGP.
- The first
Outside IP address
will be used to create the peer VPN gateway in GCP - When configuring the BGP session we will be using the Inside tunnel subnet values:
-
Calculating Cloud Router IP -
GCP link
: -
Take the
Inside tunnel subnet IP address
+ 2 -
Calculating BGP Peer IP -
AWS link
: -
Take the
Inside tunnel subnet IP address
+ 1
-
An example of these calculations is provided in the below table. Your values will vary from the provided example!
Tunnel | Example Values |
---|---|
Tunnel 1 | Sample values:
|
Open the configuration text file from the previous step and search for ikev1 pre-shared-key. Save this value for use later.
Example configuration below:
Create GCP Cloud VPN tunnels
-
Open GCP console and navigate to NETWORKING > Hybrid connectivity > VPN > Peer VPN Gateways > Create Peer VPN Gateway:
-
Name:
aws-vpn
-
Interfaces:
One interface
-
Interface 0 IP address: Enter the
Outside IP address from Tunnel 1
from your AWS site-to-site connections
-
Click Create.
-
Navigate to Cloud VPN Tunnels tab, then click Create VPN Tunnel:
Make sure the following fields are set when you create the VPN tunnel:
- VPN gateway:
ha-vpn
- Peer VPN gateway:
aws-vpn
- Cloud Router:
cloud-router
- Associated peer VPN gateway interface: outside IP of tunnel 1 (and tunnel 2 for when you set up the second VPN tunnel)
- Set a
Name
of your choice. - IKE version:
IKEv1
- Set IKE pre-shared key to what you copied earlier from the configuration txt file.
Click Create and continue.
When creating the BGP session:
-
Enter a name for your BGP session
-
Peer ASN:
65002
-
Allocate BGP IPv4 address: Select Manually
-
Cloud Router BGP IP: GCP link of
tunnel1
, which you calculated earlier -
BGP Peer IP: AWS link of
tunnel1
, which you calculated earlier
-
Click Save & Continue.
-
Click SAVE BGP CONFIGURATION.
Enable Route Propagation in AWS Route Table
-
Open AWS console and go to VPC > Route tables
-
Select the Route table of the VPC (Default)
-
Click on the Route Propagation tab then click Edit route propagation:
Check the box to enable propagation in the edit mode of the routing table.
- Click Save.
Test the connectivity
Creating instance in AWS
- Go to EC2 in your AWS account, then click Launch Instance to create the EC2 VM:
-
Use the following configuration:
- Name:
my-aws-server
- In the key pair (login) section, click create a new key pair:
- key pair name:
ec2
- key pair type:
RSA
- private key format:
.pem
- Click Create key pair.
- key pair name:
Under Network settings enable the following:
- Allow HTTPs traffic from the internet
- Allow HTTP traffic from the internet
Click on the Edit icon in the top right of the Networking Settings sections and add the following custom security group. Click add security group rule:
- Type:
Custom TCP
- Port range:
8080
- Source type:
Custom
- Source:
0.0.0.0/0
- Click Launch instance.
After the EC2 instance is created, click on View all instances and select the instance you created to view its details. Copy the Public IPv4 DNS.
Connect to your AWS instance
- After the EC2 instance is created, open Cloud Shell in your Google Cloud Platform project:
-
Upload the key (ec2.pem file) to your local Cloud Shell session running in GCP. You can do this by selecting the three dot menu at the top right of Cloud Shell and selecting
Upload
. You will be prompted to upload a file or folder in the resulting modal input box. Upload your ec2.pem file then proceed.
-
Run this command to ensure your key is not publicly viewable:
- In Cloud Shell, connect to your instance using its Public DNS. Remember to replace the Public DNS below with the one you copied previously:
Example:
- Type yes to continue connecting.
Once you log in you should see the following:
-
Run the following command in your SSH session for EC2 to install the netcat package
If prompted enter y
to continue.
Creating instance in GCP
-
In your Google Cloud Project, navigate to Compute Engine > VM instances > CREATE INSTANCE to create a Compute Engine instance with the following configuration
- Name:
my-gcp-vm
- Region:
us-central1
- Zone:
us-central1-a
- Name:
-
Under Firewall
Allow HTTP traffic
. Then click Create to create your instance. -
Once your instance is created, click SSH to connect to your instance.
-
Run the following command to install netcat. Hit enter if prompted to confirm.
Netcat from GCP to AWS
-
In your Cloud Shell session connected to your AWS EC2 instance run the following command to listen on port 8080 using netcat:
- Run the following command from your GCP VM ssh session to send a message to your AWS instance.
You should be able to see your message "Hello from GCP" in the AWS session.
Run a web server on the EC2 instance (Link)
Make sure you are still connected to your EC2 instance in Cloud Shell.
-
Press
CTRL+C
to stop listening to port 8080. -
Run the following command(s):
-
Install the Apache web server:
-
Start the web server with the command shown below
Use the public IPV4 Public IPv4 DNS you copied previously to visit the webpage of your EC2 instance. It should resemble the URL below:
- Open the URL and ensure you see a webpage similar to the following:
Create an OAuth Consent Screen
-
Open the GCP Console and go to APIs & Services > OAuth consent screen.
-
Select the user type Internal, then click Create.
-
Create an OAuth Consent Screen with the following properties:
For the Developer contact information Email addresses, use the Username of the qwiklabs user provided for this lab.
Create Self-Signed Certificate and OAuth Client
- Create a private key and certificate:
Open a new Cloud Shell session and run the openssl command to generate an RSA-2048 key.
-
Create an SSL config file called ssl_config.
-
Use the following configuration for the contents of the file. You can either edit the file using vi or click the
Open Editor
button on the top right of Cloud Shell:
-
Run the following OpenSSL command to create a certificate signing request (CSR) file.
Sign the CSR
Using a Self-Signed Certificate
When using the same private key to create a Certificate Signing Request (CSR) to sign a CSR, you create a self-signed certificate.
Self-signed certificates are not trusted by clients unless the client is configured to skip certificate validation. For example, a web browser displays a message asking you if you want to trust a self-signed certificate before allowing you to proceed to a website using a self-signed certificate. You should only use self-signed certificates for testing or ephemeral scenarios like this lab.
-
To create a self-signed certificate, run the following OpenSSL command:
Step 2: Create a self-managed SSL certificate resource
-
Now that you have created a self-signed certificate. Run the following command to create a self-managed SSL certificate in Cloud Shell. Click Authorize if prompted.
Creating an IAP connector deployment
-
Prior to performing the following steps, set the following environment variables:
Run the following commands to update service account permissions required:
-
Go to Security > Identity-Aware Proxy. Enable the API then click Go To Identity-Aware Proxy.
-
Click CONNECT NEW APPLICATION > Connect via On-Prem Connector to configure your IAP connector.
-
Click Enable APIs and Continue
-
Select the
User generated certificate
-
Select certificate you created:
my-cert
-
Select the
default
network and leaveSubnet
unselected.
- On the next page, "On-premises App Details", configure your app like below:
Your public IPV4 Public IPv4 DNS
should resemble the following {{https://ec2-52-87-221-175.compute-1.amazonaws.com}}
:
-
External facing application URL:
{{IPV4 Public IPv4 DNS}}
-
Application name:
demo-app
-
Region:
us-central1
-
On-prem endpoint type:
Fully Qualified Domain Name (FQDN)
-
Replace the following with your public
IPV4 Public IPv4 DNS
:
- FQDN endpoint:
{{IPV4 Public IPv4 DNS}}
- Protocol:
HTTP
- Port:
80
Click Done and then Submit.
After seeing the error warning sign in the status component:
- Toggle IAP for the load balancer
- Then turn it on
Testing Connectivity
-
Navigate to Network services > Load balancing and select frontend.
-
Select the HTTPS load balancer—you should see information like the following:
-
Copy the External IP address.
-
Run the following
curl
command to hit the external IP address:
You will see an IAP generated response that is true
. This means you have successfully configured IAP for your AWS resource
around 10 minutes
until the IAP generated response configures correctly. Then try the curl command again.
- This should show the 302 redirection to accounts.google.com.
- If you follow the URL, you should see a page similar to the following:
Because you used a self-signed cert, you won’t be able to access the application itself. However, this confirms that IAP is configured and is protecting traffic.
Congratulations
You created a Cloud Router and VPN Gateway in Google Cloud Platform. Then you created a Customer Gateway, Virtual Private Gateway and Site to Site VPN connection in Amazon Web Services. You then configured the bi-directional VPN tunnels to enable application connectivity. Finally you deployed BeyondCorp Enterprise, Identity Aware Proxy (IAP) On-Prem Connector to protect traffic routed to AWS.
Next Steps / Learn More
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
End your lab
When you have completed your lab, click End Lab. Your account and the resources you've used are removed from the lab platform.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
- 1 star = Very dissatisfied
- 2 stars = Dissatisfied
- 3 stars = Neutral
- 4 stars = Satisfied
- 5 stars = Very satisfied
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Manual Last Updated: December 08, 2022
Lab Last Tested: December 08, 2022
Copyright 2023 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.