Serverless infrastructure
Create Harness environments and Serverless Lambda infrastructure definitions to target your AWS account for deployment.
An infrastructure definition links a Harness environment to the AWS account, region, and deployment stage where your Serverless Lambda functions run. You create both at Deployments > Environments and reuse them across pipelines.
What you will learn
How to create a Harness environment for Serverless Lambda deployments.
How to configure an infrastructure definition with an AWS connector, region, and stage.
The AWS authentication methods supported for Serverless deployments.
How to configure dynamic provisioning for the infrastructure definition.
Create an environment
To create a new Harness environment:
Go to Deployments, expand the drop-down, and select Environments.
Select + New Environment.
Enter a name and select an environment type: Pre-Production or Production. The type affects governance policies and deployment dashboards.
Select Save.
Harness opens the environment detail page with three tabs: Configuration, Infrastructure Definitions, and References.
Create an infrastructure definition
Infrastructure definitions live inside an environment. Each definition links the environment to a specific AWS region and deployment stage.
Open the environment and select the Infrastructure Definitions tab.
Select + Create Infrastructure.
Select Serverless Lambda as the infrastructure type.
Enter a name. Harness auto-suggests one, and you can change both the name and ID.
Under Storage, choose Inline or a Git repository.
Fill in the fields under Amazon Web Services Details as described below.
Configure Simultaneous deployments and Scope to Specific Services as needed.
Select Save.
AWS infrastructure details
Connector
Yes
The AWS connector that Harness uses to authenticate with AWS. Harness uses these credentials to run serverless deploy and interact with CloudFormation.
Region
Yes
The AWS region to deploy to, for example US East (N. Virginia). This value is passed as --region to the Serverless CLI. Supports expressions and runtime input.
Stage
Yes
The deployment stage name, for example dev or prod. This value is passed as --stage to the Serverless CLI. Supports expressions and runtime input.
AWS authentication methods
The AWS connector supports several authentication methods for Serverless deployments.
Access key and secret
Static credentials stored as Harness secrets.
IAM role
The connector assumes an IAM role using sts:AssumeRole. Requires the delegate to have base credentials to call STS.
OIDC
The connector exchanges an OIDC token for temporary AWS credentials. Requires delegate version 857xx or later.
IAM Roles for Service Accounts (IRSA)
The connector uses Kubernetes service account annotations to obtain credentials via the EKS Pod Identity Webhook.
EC2 instance role
The delegate running on an EC2 instance uses the instance's IAM role.
Go to Platform > Connectors in your Harness account to add or configure an AWS connector with any of these authentication methods.
Dynamic provisioning
Instead of targeting a pre-existing AWS region and stage, you can have a provisioner step create or look up the target infrastructure at runtime and pass its outputs directly into the infrastructure definition.
The following provisioner types are supported for Serverless Lambda deployments:
Terraform
Terragrunt
Terraform Cloud
CloudFormation
Shell Script
Configure dynamic provisioning
The Provisioner Configuration section appears inside Amazon Web Services Details when you create or edit an infrastructure definition.
Under Amazon Web Services Details, expand Provisioner Configuration.
Set Map Dynamically Provisioned Infrastructure to True. A Provisioner field appears.
In the Provisioner field, select or enter the provisioner step whose outputs should populate the infrastructure fields. Use
<+input>to make this a runtime selection.Set the Connector, Region, and Stage fields to expression type and reference the provisioner outputs using
<+provisioner.OUTPUT_NAME>syntax.
For example, a CloudFormation template that outputs the required values:
Map the outputs in the infrastructure definition:
Region →
<+provisioner.region_name>Stage →
<+provisioner.stage_name>
Simultaneous deployments
By default, Harness queues deployments to the same infrastructure definition to prevent conflicts; the UI shows Simultaneous deployments: False. Set this to True to allow concurrent deployments to the same target.
Scope to specific services
By default, an infrastructure definition is available to any service in the environment. Enable Scope to Specific Services to limit the infrastructure definition so it only appears when deploying a specific set of services. This prevents teams from accidentally targeting the wrong infrastructure.
Next steps
Go to Serverless services to configure manifests and artifact sources.
Go to Serverless deployment to configure execution steps and rollback.
Last updated
Was this helpful?