Skip to main content

Function Deployment - AWS

This Playbook is part of the AWS Enrichment and Remediation Pack.#

Supported versions

Supported Cortex XSOAR versions: 6.10.0 and later.

This playbook automates the deployment of an AWS Lambda function to manage resources within an Amazon EKS cluster. It ensures that all necessary configurations are created, updated, and verified.

Setup#

  • Describe EKS Cluster: Gather essential details of the EKS cluster.
  • Create IAM Role: Set up a new IAM role for the Lambda function.
  • Create and Attach Policy: Define and attach a policy to the IAM role to grant necessary permissions.

Authentication Mode Check#

  • Verify Authentication Mode: Ensure the current authentication mode allows API access.
    • If not: Update the cluster authentication mode to permit API access.

Access Entry Configuration#

  • Create Access Entry: Establish a new access entry in the EKS cluster.
  • Associate Access Policy: Link the access policy with the created access entry.
  • Update Access Entry: Apply the latest configurations to the access entry.

VPC and Security Group Setup#

  • Describe VPCs: Identify the appropriate VPC for the Lambda function.
  • Create Security Group: Define a security group to manage Lambda function traffic.
  • Set Ingress Rules: Configure ingress rules for the security group.

VPC Endpoint Creation#

  • Create VPC Endpoint for eks-auth: Establish a VPC endpoint for EKS authentication.
  • Check for Errors: Verify if there are any errors during the creation of the VPC endpoint.
    • If errors: Handle and log them.
  • Verify VPC Endpoint Existence: Ensure the VPC endpoint already exists.
    • If exists: Proceed with the next steps.

Lambda Function Deployment#

  • Download Kubernetes Library: Fetch the necessary Kubernetes library.
  • Publish AWS Lambda Layer: Publish a new layer version for the AWS Lambda function.
  • Create Lambda Code: Develop the Lambda function code.
  • Zip Lambda Code: Compress the Lambda function code for deployment.
  • Create AWS Lambda Function: Deploy the Lambda function using the zipped code.

Resolution#

  • Final Verification: Ensure all operations have been successfully completed.
  • Completion: Confirm the deployment process is finished, ensuring robust management of EKS authentication through AWS Lambda.

This playbook provides a comprehensive, automated approach to deploying an AWS Lambda function for managing resources within an EKS cluster, efficiently handling all configurations and potential errors.

Required Integration#

AWS IAM (Identity and Access Management)#

AWS EC2 (Elastic Compute Cloud)#

AWS EKS (Elastic Kubernetes Service)#

AWS Lambda#

Dependencies#

This playbook uses the following sub-playbooks, integrations, and scripts.

Sub-playbooks#

This playbook does not use any sub-playbooks.

Integrations#

This playbook does not use any integrations.

Scripts#

  • FileCreateAndUploadV2
  • GetErrorsFromEntry
  • ZipFile
  • DownloadAndArchivePythonLibrary
  • PrintErrorEntry

Commands#

  • aws-eks-describe-cluster
  • aws-ec2-create-security-group
  • aws-eks-associate-access-policy
  • aws-ec2-create-vpc-endpoint
  • aws-eks-update-cluster-config
  • aws-iam-attach-policy
  • aws-eks-update-access-entry
  • aws-ec2-describe-vpcs
  • aws-ec2-authorize-security-group-ingress-rule
  • aws-lambda-publish-layer-version
  • aws-eks-create-access-entry
  • aws-lambda-create-function
  • aws-iam-create-policy
  • aws-iam-create-role

Playbook Inputs#


NameDescriptionDefault ValueRequired
ClusterNameThe name of the cluster.Optional
regionThe region of the cluster.Optional
FunctionNameThe name of the Lambda function.Optional
FunctionCodeEntry ID of the uploaded base64-encoded contents of the deployment package. Amazon Web Services SDK and CLI clients handle the encoding for you.Optional
FunctionRuntimeThe runtime environment for the function.Optional
FunctionHandlerThe name of the method within your code that Lambda calls to execute your function.Optional
LayerNameThe name to assign to the new Lambda layer.Optional
LayerRuntimeThe name of the method within your code that Lambda calls to execute your function.Optional
LayerArchitectureA list of compatible architectures.Optional
LibraryNameThe Python library to download and attach to the Lambda Function.
e.g.
To be able to use the kubernetes library, use 'kubernetes' and the script will download and pack its files.
Optional
LambdaRoleNameThe lambda role name to create.Optional
LambdaPolicyNameThe lambda policy name to create.Optional
SecurityGroupNameThe security group name to create.Optional

Playbook Outputs#


PathDescriptionType
AWS.EKS.DescribeCluster.nameThe name of your cluster.unknown
AWS.EKS.DescribeCluster.arnThe Amazon Resource Name (ARN) of the cluster.unknown
AWS.EKS.DescribeCluster.createdAtThe creation date of the object.unknown
AWS.EKS.DescribeCluster.versionThe Kubernetes server version for the cluster.unknown
AWS.EKS.DescribeCluster.endpointThe endpoint for your Kubernetes API server.unknown
AWS.EKS.DescribeCluster.roleArnThe Amazon Resource Name (ARN) of the IAM role that provides permissions for the Kubernetes control plane to make calls to Amazon Web Services API operations on your behalf.unknown
AWS.EKS.DescribeCluster.identityThe identity provider information for the cluster.unknown
AWS.EKS.DescribeCluster.statusThe current status of the cluster.unknown
AWS.EKS.DescribeCluster.clientRequestTokenA unique, case-sensitive identifier that you provide to ensure the idempotency of the request.unknown
AWS.EKS.DescribeCluster.platformVersionThe platform version of your Amazon EKS cluster.unknown
AWS.EKS.DescribeCluster.tagsA dictionary containing metadata for categorization and organization.unknown
AWS.EKS.DescribeCluster.idThe ID of your local Amazon EKS cluster on an Amazon Web Services Outpost.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.subnetIdsThe subnets associated with your cluster.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.securityGroupIdsThe security groups associated with the cross-account elastic network interfaces that are used to allow communication between your nodes and the Kubernetes control plane.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.clusterSecurityGroupIdThe cluster security group that was created by Amazon EKS for the cluster. Managed node groups use this security group for control-plane-to-data-plane communication.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.vpcIdThe VPC associated with your cluster.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.endpointPublicAccessWhether the public API server endpoint is enabled.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.endpointPrivateAccessThis parameter indicates whether the Amazon EKS private API server endpoint is enabled.unknown
AWS.EKS.DescribeCluster.resourcesVpcConfig.publicAccessCidrsThe CIDR blocks that are allowed access to your cluster’s public Kubernetes API server endpoint.unknown
AWS.EKS.DescribeCluster.kubernetesNetworkConfig.serviceIpv4CidrThe CIDR block that Kubernetes Pod and Service object IP addresses are assigned from.unknown
AWS.EKS.DescribeCluster.kubernetesNetworkConfig.serviceIpv6CidrThe CIDR block that Kubernetes Pod and Service IP addresses are assigned from if you created a 1.21 or later cluster with version 1.10.1 or later of the Amazon VPC CNI add-on and specified ipv6 for ipFamily when you created the cluster.unknown
AWS.EKS.DescribeCluster.kubernetesNetworkConfig.ipFamilyThe IP family used to assign Kubernetes Pod and Service objects IP addresses.unknown
AWS.EKS.DescribeCluster.logging.clusterLoggingThe cluster control plane logging configuration for your cluster.unknown
AWS.EKS.DescribeCluster.certificateAuthority.dataThe Base64-encoded certificate data required to communicate with your cluster.unknown
AWS.EKS.DescribeCluster.encryptionConfig.resourcesSpecifies the resources to be encrypted. The only supported value is secrets.unknown
AWS.EKS.DescribeCluster.encryptionConfig.providerKey Management Service (KMS) key.unknown
AWS.EKS.DescribeCluster.connectorConfig.activationIdA unique ID associated with the cluster for registration purposes.unknown
AWS.EKS.DescribeCluster.connectorConfig.activationCodeA unique code associated with the cluster for registration purposes.unknown
AWS.EKS.DescribeCluster.connectorConfig.activationExpiryThe expiration time of the connected cluster.unknown
AWS.EKS.DescribeCluster.connectorConfig.providerThe cluster’s cloud service provider.unknown
AWS.EKS.DescribeCluster.connectorConfig.roleArnThe Amazon Resource Name (ARN) of the role to communicate with services from the connected Kubernetes cluster.unknown
AWS.EKS.DescribeCluster.health.issuesAn object representing the health issues of your local Amazon EKS cluster on an Amazon Web Services Outpost.unknown
AWS.EKS.DescribeCluster.outpostConfig.outpostArnsAn object representing the configuration of your local Amazon EKS cluster on an Amazon Web Services Outpost.unknown
AWS.EKS.DescribeCluster.outpostConfig.controlPlaneInstanceTypeThe Amazon EC2 instance type used for the control plane.unknown
AWS.EKS.DescribeCluster.outpostConfig.controlPlanePlacementAn object representing the placement configuration for all the control plane instances of your local Amazon EKS cluster on an Amazon Web Services Outpost.unknown
AWS.EKS.DescribeCluster.accessConfig.bootstrapClusterCreatorAdminPermissionsSpecifies whether or not the cluster creator IAM principal was set as a cluster admin access entry during cluster creation time.unknown
AWS.EKS.DescribeCluster.accessConfig.authenticationModeThe current authentication mode of the cluster.unknown
AWS.IAM.Roles.RoleNameThe friendly name that identifies the role.unknown
AWS.IAM.Roles.RoleIdThe stable and unique string identifying the role.unknown
AWS.IAM.Roles.ArnThe Amazon Resource Name (ARN) specifying the role.unknown
AWS.IAM.Roles.CreateDateThe date and time, when the role was created.unknown
AWS.IAM.Roles.PathThe path to the role.unknown
AWS.IAM.Roles.AssumeRolePolicyDocumenthe policy that grants an entity permission to assume the role.unknown
AWS.IAM.Roles.DescriptionA description of the role that you provide.unknown
AWS.IAM.Roles.MaxSessionDurationThe maximum session duration (in seconds) for the specified role.unknown
AWS.IAM.Policies.PolicyNameThe friendly name (not ARN) identifying the policy.unknown
AWS.IAM.Policies.PolicyIdThe stable and unique string identifying the policy.unknown
AWS.IAM.Policies.ArnThe Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources.unknown
AWS.IAM.Policies.PathThe path to the policy.unknown
AWS.IAM.Policies.DefaultVersionIdThe identifier for the version of the policy that is set as the default version.unknown
AWS.IAM.Policies.DescriptionA friendly description of the policy.unknown
AWS.IAM.Policies.CreateDateThe date and time, in ISO 8601 date-time format , when the policy was created.unknown
AWS.IAM.Policies.UpdateDateThe date and time, in ISO 8601 date-time format , when the policy was last updated.unknown
AWS.EKS.CreateAccessEntry.clusterNameThe name of the cluster.unknown
AWS.EKS.CreateAccessEntry.principalArnThe ARN of the IAM principal for the access entry.unknown
AWS.EKS.CreateAccessEntry.kubernetesGroupsA list of names that you’ve specified in a Kubernetes RoleBinding or ClusterRoleBinding object so that Kubernetes authorizes the principalARN access to cluster objects.unknown
AWS.EKS.CreateAccessEntry.accessEntryArnThe ARN of the access entry.unknown
AWS.EKS.CreateAccessEntry.createdAtThe creation date of the object.unknown
AWS.EKS.CreateAccessEntry.modifiedAtThe date and time for the last modification to the object.unknown
AWS.EKS.CreateAccessEntry.tagsA dictionary containing metadata for categorization and organization.unknown
AWS.EKS.CreateAccessEntry.usernameThe name of a user that can authenticate to the cluster.unknown
AWS.EKS.CreateAccessEntry.typeThe type of the access entry.unknown
AWS.EKS.AssociatedAccessPolicy.clusterNameThe name of your cluster.unknown
AWS.EKS.AssociatedAccessPolicy.principalArnThe ARN of the IAM principal for the AccessEntry.unknown
AWS.EKS.AssociatedAccessPolicy.policyArnThe ARN of the AccessPolicy.unknown
AWS.EKS.AssociatedAccessPolicy.associatedAtThe date and time the AccessPolicy was associated with an AccessEntry.unknown
AWS.EKS.AssociatedAccessPolicy.modifiedAtThe date and time for the last modification to the object.unknown
AWS.EKS.AssociatedAccessPolicy.accessScope.typeThe scope type of an access policy.unknown
AWS.EKS.AssociatedAccessPolicy.accessScope.namespacesA Kubernetes namespace that an access policy is scoped to.unknown
AWS.EKS.UpdateAccessEntry.clusterNameThe name of your cluster.unknown
AWS.EKS.UpdateAccessEntry.principalArnThe ARN of the IAM principal for the access entry.unknown
AWS.EKS.UpdateAccessEntry.kubernetesGroupsA list of names that you’ve specified in a Kubernetes RoleBinding or ClusterRoleBinding object so that Kubernetes authorizes the principalARN access to cluster objects.unknown
AWS.EKS.UpdateAccessEntry.accessEntryArnThe ARN of the access entry.unknown
AWS.EKS.UpdateAccessEntry.createdAtThe creation date of the object.unknown
AWS.EKS.UpdateAccessEntry.modifiedAtThe date and time for the last modification to the object.unknown
AWS.EKS.UpdateAccessEntry.tagsMetadata that assists with categorization and organization. Each tag consists of a key and an optional value.unknown
AWS.EKS.UpdateAccessEntry.usernameThe name of a user that can authenticate to your cluster.unknown
AWS.EKS.UpdateAccessEntry.typeThe type of the access entry.unknown
AWS.Lambda.Layers.LayerVersionArnThe ARN of the layer version.unknown
AWS.Lambda.Layers.LayerArnThe ARN of the layer.unknown
AWS.Lambda.Layers.DescriptionThe description of the version.unknown
AWS.Lambda.Layers.CreatedDateThe date that the layer version was created, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD).unknown
AWS.Lambda.Layers.VersionThe version number.unknown
AWS.Lambda.Layers.CompatibleRuntimesThe layer’s compatible runtimes.unknown
AWS.Lambda.Layers.CompatibleArchitecturesThe layer’s compatible architectures.unknown
AWS.Lambda.Functions.FunctionNameThe name of the function.unknown
AWS.Lambda.Functions.FunctionArnThe function’s Amazon Resource Name (ARN).unknown
AWS.Lambda.Functions.RuntimeThe identifier of the function’s runtime. Runtime is required if the deployment package is a .zip file archive.unknown
AWS.Lambda.Functions.RoleThe function’s execution role.unknown
AWS.Lambda.Functions.HandlerThe function that Lambda calls to begin running your function.unknown
AWS.Lambda.Functions.DescriptionThe function’s description.unknown
AWS.Lambda.Functions.PackageTypeThe type of deployment package. Set to Image for container image and set Zip for .zip file archive.unknown
AWS.Lambda.Functions.LastModifiedThe date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD).unknown
AWS.Lambda.Functions.TimeoutThe amount of time in seconds that Lambda allows a function to run before stopping it.unknown
AWS.Lambda.Functions.VpcConfig.SubnetIdsA list of VPC subnet IDs.unknown
AWS.Lambda.Functions.VpcConfig.SecurityGroupIdsA list of VPC security group IDs.unknown
AWS.Lambda.Functions.VpcConfig.VpcIdThe ID of the VPC.unknown
AWS.Lambda.Functions.VpcConfig.Ipv6AllowedForDualStackAllows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.unknown
AWS.EKS.UpdateCluster.clusterNameThe name of the cluster.unknown
AWS.EKS.UpdateCluster.idThe ID of the update.unknown
AWS.EKS.UpdateCluster.statusThe status of the update.unknown
AWS.EKS.UpdateCluster.typeThe type of the update.unknown
AWS.EKS.UpdateCluster.paramsThe parameters of the update.unknown
AWS.EKS.UpdateCluster.createdAtThe creation date of the object.unknown
File.NameThe name of the file.String
File.EntryIDThe entry ID of the file.String
File.TypeThe file type.String
File.ExtensionThe file extension.String
File.SHA256The SHA256 hash of the file.String
ZipFile.ZippedFileThe zipped file.string
AWS.EC2.Vpcs.VpcEndpoint.VpcEndpointIdThe ID of the endpoint.unknown
AWS.EC2.Vpcs.VpcEndpoint.StateThe state of the VPC endpoint.unknown
AWS.EC2.Vpcs.VpcEndpoint.ServiceNameThe service name of the VPC endpoint.unknown
AWS.EC2.Vpcs.VpcEndpoint.VpcIdThe ID of the VPC to which the endpoint is associated.unknown
AWS.EC2.Vpcs.VpcEndpoint.EndpointTypeThe type of the VPC endpoint.unknown
AWS.EC2.Vpcs.VpcIdThe ID of the VPC.unknown
AWS.EC2.Vpcs.AccountIdThe ID of the AWS account with which the EC2 instance is associated. This key is only present when the parameter "AWS organization accounts" is provided.unknown
AWS.EC2.Vpcs.StateThe current state of the VPC.unknown
AWS.EC2.Vpcs.CidrBlockThe primary IPv4 CIDR block for the VPC.unknown
AWS.EC2.Vpcs.Tags.KeyThe key of the tag.unknown
AWS.EC2.Vpcs.Tags.ValueThe value of the tag.unknown
AWS.EC2.Vpcs.Tags.Ipv6CidrBlockAssociationSet.AssociationIdThe association ID for the IPv6 CIDR block.unknown
AWS.EC2.Vpcs.Tags.Ipv6CidrBlockAssociationSet.Ipv6CidrBlockThe IPv6 CIDR block.unknown
AWS.EC2.Vpcs.Tags.Ipv6CidrBlockAssociationSet.Ipv6CidrBlockState.StateThe state of the CIDR block.unknown
AWS.EC2.Vpcs.Tags.Ipv6CidrBlockAssociationSet.Ipv6CidrBlockState.StatusMessageA message about the status of the CIDR block, if applicable.unknown
AWS.EC2.Vpcs.Tags.CidrBlockAssociationSet.AssociationIdThe association ID for the IPv4 CIDR block.unknown
AWS.EC2.Vpcs.Tags.CidrBlockAssociationSet.CidrBlockThe IPv4 CIDR block.unknown
AWS.EC2.Vpcs.Tags.CidrBlockAssociationSet.CidrBlockState.StateThe state of the CIDR block.unknown
AWS.EC2.Vpcs.Tags.CidrBlockAssociationSet.CidrBlockState.StatusMessageA message about the status of the CIDR block, if applicable.unknown
AWS.EC2.SecurityGroups.GroupNameThe name of the security group.unknown
AWS.EC2.SecurityGroups.DescriptionA description for the security group.unknown
AWS.EC2.SecurityGroups.VpcIdThe ID of the VPC.unknown
AWS.EC2.SecurityGroups.GroupIdThe ID of the security group.unknown
AWS.EC2.SecurityGroups.AccountIdThe ID of the AWS account with which the EC2 instance is associated. This key is only present when the parameter "AWS organization accounts" is provided.unknown
ErrorEntriesContents of the errors associated with the entry/entries.unknown

Playbook Image#


Function Deployment - AWS