07-21-2020 01:33 AM - edited 04-09-2021 03:05 AM
Hello Cisco Community! Cisco Secure is moving forward with Cisco hosted SecureX Integration Modules, where no serverless relay or docker container is needed any more. To switch to the Cisco hosted version of your SecureX Integration Module, just follow these easy steps.
Serverless environment
You can still use your existing configured serverless modules. Both configuration options are still available, AWS serverless configuration and Cisco hosted Modules.
If you are moving to the Cisco hosted version of the Integration Modules the steps below are not necessary.
Relays for Cisco SecureX 3rd Party Modules enable communication between Cisco SecureX and 3rd Party vendors. The Serverless Template uses AWS as an example, that is very inexpensive and easy to deploy: https://github.com/CiscoSecurity/tr-05-serverless-relay
This Guide is separated into 3 parts
Part 1&2 just need to be done once.
Which Modules are possible today?
To install, configure and maintain the Serverless Relay, which is an App hosted by Amazon, we need some components. Enclosed a short description what is needed. This is an overview. The page will guide you step-by-step through the necessary steps to make your Serverless Relay up and running. |
After you configured the Configuration of the WebApp locally on your endpoint, there is a simple command to upload or update your WebApp on AWS.
During the configuration of the Module (AWS WebApp) locally on your endpoint, all needed Authentication Tokens and URLs are generated, which are used to configure your 3rd Party Module in SecureX.
Why we need the AWS environment? After your module is configured, just start an investigation. The UI shows which Modules have been queried.
In this section we will Guide you to prepare an AWS environment used to provide the virtual apps for your SecureX Modules. We will do just a few steps.
Note, this Step-by-Step Guide shows how to generate an AWS Account for Serverless Applications. Keep in mind, if you have already other components configured in AWS, your Screen may look like a little bit different than the screenshots shown in this guide.
The next Steps will guide you through the implementation of the AWS environment, which acts as a "Service Proxy" between Cisco SecureX/CTR Modules and 3rd Party Modules.
Benefit of this approach are:
AWS Environment
Configuring the AWS environment is necessary one time. You can use the Server Relay for several apps. All the code (Policy Templates as .JSON File) on GitHub is already prepared, so you easily copy/paste the .JSON code, instead of manually generating the policies. This makes it really simple to configure your AWS environment.
Keep in mind, some naming are mandatory!
AWS NEW User Object Step7: The Last step shows the Summary and the downloadable CSV File. The File includes
your Access Key ID and the Secret Access Key. We will need this information later to generate all the authentication token.
Keep the file in a secure way. It can downloaded only once. We need the Secret Key later to generate |
Rename the downloaded file from download.csv to serverless.csv.
Note: All documentation on Github uses the "serverless" naming. When testing around the first time, i recommend to use the same naming convention. |
Spoiler
Once the user is created and the credentials are downloaded, the best way to store that data is to put it into your AWS credentials file usually located on ~/.aws/credentials (Linux and Mac) or %USERPROFILE%\.aws\credentials (Windows). So make sure to add the user's credentials from the serverless.csv file to the AWS credentials file (manually create an empty one if missing) as a separate profile: |
In this step we are generating a Deployment Policy as outlined https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/HOWTO.md.
This Policy permits an AWS user to install a Web Application in AWS. Cisco already provides the Policy as a .JSON File.
So you can just use Copy/Paste to generate the policy: https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/ZappaLambdaDeploymentPolicy.json.
GitHub Documentation.
Step: AWS Deployment Policy: Copy/Paste the content into a Text file: https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/ZappaLambdaDeploymentPolicy.json
Before copying the policy to AWS, you have to change the Account ID in the .JSON File (shown in Row 14):
Replace <ACCOUNT_ID> with your real Account ID, so finally the line looks like this: "arn:aws:iam::123456789012x:role/*ZappaLambdaExecutionRole"
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iam:AttachRolePolicy", "iam:GetRole", "iam:CreateRole", "iam:PassRole", "iam:PutRolePolicy" ], "Resource": [ "arn:aws:iam::<ACCOUNT_ID>:role/*ZappaLambdaExecutionRole" ] }, |
|
|
Step: AWS Deployment Policy: Name the Policy ZappaLambdaDeploymentPolicy (so we have the same naming than on
GitHub) and add a Description. Click the Create Policy Button.
In this step we are generating an execution policy. This policy includes the smallest set of permissions. With this Policy, the user is
allowed to use the SecureX Relay only: https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/HOWTO.md
a .JSON format: https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/ZappaLambdaExecutionPolicy.json
The provided code can be directly copied into the AWS configuration UI.
## Always use the latest code from Github ## { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:*" ], "Resource": "arn:aws:logs:*:*:*" }, { "Effect": "Allow", "Action": [ "lambda:InvokeFunction" ], "Resource": [ "*" ] } ] } |
In this step we are generating a Permission Role for the account. You can find details a the GitHub Documentation why this Role is useful: https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/HOWTO.md
Info from Github:
Spoiler
The default IAM policy created by Zappa for executing Lambdas is very permissive. It grants access to all actions for all resources for types CloudWatch, S3, Kinesis, SNS, SQS, DynamoDB, and Route53; lambda:InvokeFunction for all Lambda resources; Put to all X-Ray resources; and all Network Interface operations to all EC2 resources. While this allows most Lambdas to work correctly with no extra permissions, it is generally not an acceptable set of permissions for most continuous integration pipelines or production deployments. Instead, you will probably want to manually manage your IAM policies. That is why in the Zappa Settings the NOTE. After having properly configured your |
Note: Using the name tr-serverless-relay-ZappaLambdaExecutionRole is essential. Using a different naming will break functionality. |
Step: AWS Execution Role: Provide the name tr-serverless-relay-ZappaLambdaExecutionRole for the Role.
Note: Using the name tr-serverless-relay-ZappaLambdaExecutionRole is essential! |
Step: AWS Execution Role: Role was created successfully
Step: AWS Execution Role: Open the newly generated Execution Role, select the Trust relationships tab.
Step: AWS Execution Role: Click the "Edit trust relationship" Button.
Step: AWS Execution Role: By default, the Service field will be equal to lambda.amazonaws.com.
Add a value to a list: apigateway.amazonaws.com.
## Before Change ## |
## After Change ## |
Info: Once again, when configuring new, take a look on GitHub if there was any recent change. |
Step: AWS Execution Role: Click the "Update Trust Policy" Button.
So what we have configured so far?
Info: Configuring AWS must be done one time. Afterwards multiple Lambda Apps (3rd Party Modules) are hosted as Lambda functions. |
Q: I´m getting an AWS related error message during uploading or configuring. What i can do?
A: Take a look at the AWS common error page: https://github.com/CiscoSecurity/tr-05-serverless-relay/blob/develop/aws/CommonErrors.md
Q: I´m getting an error message that zappa is not available.
A: Take a look if your python virtual environment is running.
Q: I´m getting an error message that the local file cannot be packed.
A: Switch to root in your Terminal Windows using e.g. sudo su.
Q: I removed an application from AWS, no i cannot deploy it any more.
A: Take a look if the s3_bucket is still available on AWS. In addition try to use zappa update dev.
This is great. Really helpful! Is there a specific reason to use Zappa over something more widely used like Terraform?
Hello @DanielMidgley1568 , two things I want to mention here.
If you want to host your own modules somewhere in the cloud, feel free
Greetings, Thorsten
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: