Skip to main content

CCM AWS Permissions

When creating a Harness IAM Role in AWS for CCM, there are many different permissions sets based on the features you are trying to leverage in specific accounts. This guide is meant to cover all the different features of CCM and the permissions you need to assign to enable them.

To enable specific features on a connector you need to set a specific string in the featuresEnabled field (list) in the connector YAML. The keys for each feature are listed in the sections below.

Testing Permissions

No matter the feature you are using, when testing connector health in the UI Harness attempts to check it's own access using iam:SimulatePrincipalPolicy.

{
"Statement": [
{
"Action": "iam:SimulatePrincipalPolicy",
"Effect": "Allow",
"Resource": "arn:aws:iam::{AWS_ACCOUNT_ID}:role/{ROLE_NAME}",
"Sid": ""
}
],
"Version": "2012-10-17"
}

Cost Ingestion

featuresEnabled: BILLING

To ingest cost from AWS, Harness leverages a Cost and Usage Report (CUR) that is generated by AWS (CUR 2.0 not supported). These reports are delivered to an S3 bucket in your payer account. When assigning permissions, we will need access to both read the bucket where the CUR reports are being delivered and write to a Harness owned bucket so that we can receive the data and load it into your Harness account.

We also include some permissions for Organizations so we can collect things like account names, account tags and access to see the definition of the CUR to make sure it matches Harness standards.

Finally we ask for ce:GetRightsizingRecommendation to collect Compute Optimizer recommendations at the organization level, to be shown in Harness Recommendations.

{
"Statement": [
{
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:GetBucketLocation"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::{YOUR_CUR_BUCKET_NAME}/*",
"arn:aws:s3:::{YOUR_CUR_BUCKET_NAME}"
],
"Sid": "readBillingBucket"
},
{
"Action": [
"s3:PutObjectAcl",
"s3:PutObject",
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::{HARNESS_S3_BUCKET}*/*",
"arn:aws:s3:::{HARNESS_S3_BUCKET}*"
],
"Sid": "writeHarnessBucket"
},
{
"Action": [
"organizations:List*",
"organizations:Describe*",
"cur:DescribeReportDefinitions",
"ce:GetRightsizingRecommendation
],
"Effect": "Allow",
"Resource": "*",
"Sid": "readOrg"
}
],
"Version": "2012-10-17"
}

In the above policy {YOUR_CUR_BUCKET_NAME} needs to be replaced with your S3 bucket where CUR reports are being delivered.

{HARNESS_S3_BUCKET} is the Harness S3 bucket where your CUR will be copied to. This bucket changes based on your Harness account, but most customers will use ce-customer-billing-data-prod.

Events/Inventory

featuresEnabled: VISIBILITY

To let Harness collect inventory data (used in dashboards) you need to give read permissions to EC2, RDS, ECS and CloudWatch as well as collect Compute Optimizer recommendations for EC2.

The ECS permissions are also used to generate recommendations to best-fit your task sizing for cost savings.

{
"Statement": [
{
"Action": [
"rds:DescribeDBSnapshots",
"rds:DescribeDBSnapshotAttributes",
"rds:DescribeDBInstances",
"rds:DescribeDBClusters",
"ecs:ListTasks",
"ecs:ListServices",
"ecs:ListContainerInstances",
"ecs:ListClusters*",
"ecs:DescribeTasks",
"ecs:DescribeServices",
"ecs:DescribeContainerInstances",
"ecs:DescribeClusters",
"ec2:DescribeVolumes",
"ec2:DescribeSnapshots",
"ec2:DescribeRegions",
"ec2:DescribeInstances*",
"cloudwatch:GetMetricData",
"ce:GetRightsizingRecommendation
],
"Effect": "Allow",
"Resource": "*",
"Sid": "inventory"
}
],
"Version": "2012-10-17"
}

Asset Governance

featuresEnabled: GOVERNANCE

When enabling asset governance, it is best practice to start with a read-only policy so you can run rules in dry-run, receive out-of-the-box recommendations, and begin to create your own custom governance recommendations.

We suggest you use the AWS-provided ViewOnlyAccess policy which will allow Harness to access AWS resources in a read-only manner.

arn:aws:iam::aws:policy/job-function/ViewOnlyAccess

Once you are ready to perform actions using governance, you can create a custom policy to allow only the actions you want to take via governance, or use built-in policies to provide whatever access you are comfortable with.

For example if you are going to begin auto-deleting snapshots using governance, you might assign ec2:DeleteSnapshot or arn:aws:iam::aws:policy/AmazonEC2FullAccess.

Commitment Orchestrator

featuresEnabled: COMMITMENT_ORCHESTRATOR

To start getting your commitment coverage information you can provide read-only access in your payer account.

{
"Statement": [
{
"Action": [
"savingsplans:DescribeSavingsPlans",
"organizations:DescribeOrganization",
"ec2:DescribeReservedInstancesOfferings",
"ec2:DescribeReservedInstances",
"ec2:DescribeInstanceTypeOfferings",
"ce:GetSavingsPlansUtilizationDetails",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansCoverage",
"ce:GetReservationUtilization",
"ce:GetReservationCoverage",
"ce:GetDimensionValues"
],
"Effect": "Allow",
"Resource": "*",
"Sid": "viewcoverage"
}
],
"Version": "2012-10-17"
}

Once you set up the orchestrator and are ready to approve recommendations, you can give access to make purchases.

{
"Statement": [
{
"Action": [
"ec2:PurchaseReservedInstancesOffering",
"ec2:ModifyReservedInstances",
"ec2:GetReservedInstancesExchangeQuote",
"ec2:DescribeReservedInstancesModifications",
"ec2:DescribeInstanceTypeOfferings",
"ec2:AcceptReservedInstancesExchangeQuote"
],
"Effect": "Allow",
"Resource": "*",
"Sid": "purchase"
}
],
"Version": "2012-10-17"
}

Autostopping

featuresEnabled: OPTIMIZATION

Autostopping has many ways to optimize resource usage and reduce costs. Across AWS, Azure, GCP and the different compute and routing products between them, there are many possible permissions needed. Based on your cloud platform, compute, and application architecture you can use the following information to build a least-privileged policy.

AWS

EC2 with Fixed Schedules

PolicyUsage
ec2:DescribeInstancesList VMS in Harness UI for rule creation and in rule details page. This will be used in other operations while starting and stopping the VM.
ec2:CreateTagsCreate tags on the EC2 while creating an Autostopping rule.
ec2:StartInstancesStart EC2
ec2:StopInstancesStop EC2

Spot EC2 with Fixed schedules

PolicyUsage
ec2:DescribeVolumes ec2:CreateImage ec2:DescribeImagesCreating Snapshot for Spot VM
ec2:TerminateInstancesSpot VMs are terminate during cool down instead of stopping.
ec2:DeregisterImage ec2:DeleteSnapshotDelete snapshot after deleting Autostopping rule
ec2:RequestSpotInstances ec2:DescribeSpotInstanceRequests ec2:DescribeAddressesCreate spot VM during warm up
ec2:RunInstancesCreate on demand instance in case spot VM creation fails

EC2 with ALB

PolicyUsage
acm:ListCertificatesDescribe certificates in create ALB flow
ec2:DescribeVpcsList VPCs in create ALB flow
ec2:DescribeSecurityGroupsList security groups in create ALB flow
elasticloadbalancing:DescribeLoadBalancersDescribe load balancers in create ALB flow
iam:ListRolesLambda requires a role to execute and push the logs to cloud watch. We have a separate role for that. iam:ListRoles is used in code to list roles and identify the role created for lambda.
ec2:DescribeSubnetsList subnets for the selected VPC while creating ALB.
elasticloadbalancing:CreateLoadBalancerCreate ALB. Needed only if customer wants to create ALB from Harness
elasticloadbalancing:SetSecurityGroupsAttach security groups to ALB. Needed only if customer wants to create ALB from Harness.
elasticloadbalancing:DescribeTargetGroupsDescribe target group. This is used to get details of lambda target group and EC2 target group
elasticloadbalancing:CreateTargetGroupCreate lambda target group and health check target group
elasticloadbalancing:AddTagsAdd tags to Harness created target groups
lambda:GetFunctionGet lambda function details
lambda:CreateFunctionCreate lambda function
iam:PassRoleWe specify the lambda role when we try to create lambda. Create lambda with role in request will succeed only if this permission is present
lambda:AddPermissionThis is needed to allow the lambda Target Group to execute the lambda.
elasticloadbalancing:RegisterTargetsRequired to add lambda to target group

ASG with Fixed schedules

PolicyUsage
autoscaling:DescribeAutoScalingGroupsList ASG
autoscaling:UpdateAutoScalingGroupSet the desired capacity of ASG during warm up and cool down operations
ec2:DescribeSpotPriceHistoryGet the spot price for savings computation

ASG with ALB

PolicyUsage
rds:DescribeDBInstancesList RDS instances
rds:DescribeDBClustersList RDS clusters
rds:ListTagsForResourceList tags associated with RDS
rds:StartDBInstanceStart RDS Instance
rds:StartDBClusterStart RDS Cluster
rds:StopDBInstanceStop RDS Instance
rds:StopDBClusterStop RDS Cluster

ECS with Fixed schedules

PolicyUsage
ecs:ListClustersList ECS clusters
tag:GetResourcesList tags for selecting ECS service by tag
ecs:ListServicesList ECS services
ecs:ListTasksList tasks for ECS service
ecs:DescribeServicesDescribe ECS services
ecs:UpdateServiceNeeded set the desired task count while warming and cooling down
ecs:DescribeTaskDefinitionDescribe ECS Task
ecs:DescribeTasksDescribe ECS Tasks

ECS with ALB

This is a combination of permissions for ECS with Fixed schedules and EC2 with ALB policies.

Provisioning Autostopping Proxy

PolicyUsage
ec2:DescribeInstanceTypeOfferingsList machine types available for Proxy
ec2:DescribeKeyPairsList key pairs for Proxy
ec2:RunInstancesCreate Proxy VM
secretsmanager:GetSecretValuePermission to read TLS certificate and secret. Needed only if TLS is used.
ec2:AllocateAddressAllocate static IP
ec2:DescribeVpcsList VPCs in create proxy flow
ec2:DescribeSecurityGroupsList security groups in create proxy flow
ec2:DescribeSubnetsList subnets for the selected VPC while creating ALB.
ec2:TerminateInstancesDelete the Proxy VM while deleting proxy Scope of this permission can be reduced to only proxy VMs.
ec2:DescribeImagesDescribe the image for proxy
ec2:AssociateAddressAssociating address with VM
ec2:DisassociateAddressDisassociate address while deleting proxy
ec2:ReleaseAddressRelease address while deleting proxy
ec2:ModifyInstanceAttributeModify security group of proxy VM if needed