Setting up IAM by hand
The quickest way to give Delegaris access is the two CloudFormation templates (Member account role). If you manage IAM with Terraform, the CDK or the console instead, these are the same permissions as plain IAM policies. They are generated from the templates, so the two never differ.
Every file is in the iam/policies folder of the release repository and inside the Docker image and Linux package (/app/iam/policies, /opt/delegaris/current/iam/policies).
Two roles are involved:
- The service's own role ("hub"), in the account Delegaris runs in. Its only job is to assume a role in each account you manage, and to read AWS list prices.
DelegarisRolein each managed account, which trusts the hub role and allows listing, starting, stopping and tagging.
If Delegaris signs in to an account with that account's own access keys, or with IAM Identity Center, only the managed-account permissions are needed, attached to that user or permission set.
The service's own role
Create a role for EC2 (for an instance running Delegaris) named delegaris-hub.
Trust policy (hub-trust-ec2.json):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Permissions (hub-permissions.json):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::*:role/DelegarisRole"
},
{
"Sid": "ReadListPrices",
"Effect": "Allow",
"Action": "pricing:GetProducts",
"Resource": "*"
}
]
}
If you renamed DelegarisRole in the member accounts, change the role name in the first statement to match.
Optional extras, each its own policy:
| File | Add it when |
|---|---|
hub-backup-bucket.json | Backups are copied to S3 (BACKUP_S3_BUCKET). Replace YOUR_BACKUP_BUCKET. |
hub-audit-bucket.json | The activity log is copied to S3. Replace YOUR_AUDIT_BUCKET. |
Then attach the role to the instance through an instance profile. Running somewhere other than EC2, give these permissions to the IAM user or role whose credentials Delegaris uses instead.
The role in each managed account
Create a role named DelegarisRole in every account Delegaris should manage.
Trust policy (member-trust.json). Replace HUB_ACCOUNT_ID with the account the service runs in, and the role name if yours differs:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::HUB_ACCOUNT_ID:role/delegaris-hub"
},
"Action": "sts:AssumeRole"
}
]
}
With an external ID (enter the same value on the account in Delegaris), use member-trust-with-external-id.json instead.
Permissions: attach the policy for each service the account manages. Tick the same services on the account in Delegaris.
| File | Allows |
|---|---|
member-ec2.json | EC2 instances: list, start, stop, reboot, tag |
member-rds.json | RDS instances, Aurora, DocumentDB and Neptune clusters |
member-autoscaling.json | Auto Scaling groups: list, scale to zero and back, tag |
member-ecs.json | ECS services: list, scale to zero and back, restart, tag |
member-eks.json | EKS managed node groups: list, scale to zero and back, tag |
member-redshift.json | Redshift clusters: list, pause, resume, reboot, tag |
member-sagemaker.json | SageMaker notebook instances: list, start, stop, tag |
member-lightsail.json | Lightsail instances: list, start, stop, reboot, tag |
member-read-schedules.json | Optional, read-only: AWS Instance Scheduler's configuration table and Systems Manager Quick Setup schedules, for Read from the scheduler |
member-all-services.json | Everything above except reading schedules, in one policy |
For example, member-ec2.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListAndControlInstances",
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:RebootInstances"
],
"Resource": "*"
},
{
"Sid": "TagInstances",
"Effect": "Allow",
"Action": [
"ec2:CreateTags",
"ec2:DeleteTags"
],
"Resource": "arn:aws:ec2:*:*:instance/*"
},
{
"Sid": "StartEncryptedInstances",
"Effect": "Allow",
"Action": "kms:CreateGrant",
"Resource": "*",
"Condition": {
"Bool": {
"kms:GrantIsForAWSResource": "true"
}
}
}
]
}
The tag permissions are limited to the resource types Delegaris manages. kms:CreateGrant lets EC2 start instances whose disks are encrypted with your own KMS key; the key's policy must allow the role too.
Terraform
The same in Terraform, for one managed account with EC2 and RDS:
resource "aws_iam_role" "delegaris" {
name = "DelegarisRole"
assume_role_policy = file("${path.module}/policies/member-trust.json")
max_session_duration = 3600
}
resource "aws_iam_role_policy" "delegaris_ec2" {
name = "delegaris-ec2"
role = aws_iam_role.delegaris.id
policy = file("${path.module}/policies/member-ec2.json")
}
resource "aws_iam_role_policy" "delegaris_rds" {
name = "delegaris-rds"
role = aws_iam_role.delegaris.id
policy = file("${path.module}/policies/member-rds.json")
}
(Edit HUB_ACCOUNT_ID in the trust policy first, or build it with jsonencode.)
Checking it
Add the account under Accounts with the role's ARN and press Test connection. Delegaris assumes the role and tries a read for each service ticked on the account, and says which, if any, are refused. See Adding accounts.