Credentials

The credential resource is the way Cloud Plans connect to your Clouds:

  • To AWS accounts CS connects using a remote role you shuld create in your AWS Account IAM

  • To Azure Subscriptions CS connects using Service Principal

  • To Google Cloud projects CS connects using a your project ID

AWS

We use remote roles to connect to Accounts and manage the desired resources (best Security Practice). All you have to do is:

  • Create a role trusting the external account 605134468875 with the following permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ec2:RebootInstances",
                "sts:GetSessionToken",
                "ec2:DescribeInstances",
                "ec2:StartInstances",
                "ec2:DescribeInstanceAttribute",
                "ec2:DescribeRegions",
                "ec2:DescribeInstanceTypes",
                "sts:GetCallerIdentity",
                "ec2:StopInstances",
                "ec2:DescribeInstanceStatus"
            ],
            "Resource": "*"
        }
    ]
}

This can be enhaced in Security with the following recommendation:

  • Tag your desired instances with something like "cloudsscheduler"

  • Edit the policy with the following:

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "exampleCSPolicyWithCondition",
			"Effect": "Allow",
			"Action": [
				"ec2:DescribeHosts",
				"ec2:RebootInstances",
				"ec2:DescribeInstances",
				"ec2:StartInstances",
				"ec2:DescribeInstanceAttribute",
				"ec2:DescribeInstanceTypes",
				"ec2:DescribeFleetInstances",
				"ec2:RunInstances",
				"ec2:DescribeClassicLinkInstances",
				"ec2:StopInstances",
				"ec2:DescribeInstanceStatus"
			],
			"Resource": "*",
			"Condition": {
				"StringLikeIfExists": {
					"aws:ResourceTag/cloudsscheduler": "True"
				}
			}
		}
	]
}

Azure

Cloud Plans needs Service Principals with the access key. It is recommended to have one SP per Subscription. The recommended policy can be as follows:

{
    "properties": {
        "roleName": "cloudsscheduler",
        "description": "",
        "assignableScopes": [
            "/subscriptions/1a2e3b4e4d-0a0a-1b1b-aaaa-aaa000111aaa" (an example)
        ],
        "permissions": [
            {
                "actions": [
                    "Microsoft.Compute/locations/runCommands/read",
                    "Microsoft.Compute/availabilitySets/vmSizes/read",
                    "Microsoft.Compute/hostGroups/hosts/read",
                    "Microsoft.Compute/hostGroups/read",
                    "Microsoft.Compute/proximityPlacementGroups/read",
                    "Microsoft.Compute/hostGroups/hosts/hostSizes/read",
                    "Microsoft.Compute/virtualMachines/read",
                    "Microsoft.Compute/virtualMachines/start/action",
                    "Microsoft.Compute/virtualMachines/powerOff/action",
                    "Microsoft.Compute/virtualMachines/restart/action",
                    "Microsoft.Compute/virtualMachines/vmSizes/read",
                    "Microsoft.Compute/virtualMachines/runCommands/read",
                    "Microsoft.Compute/virtualMachines/runCommands/write",
                    "Microsoft.Compute/sharedVMExtensions/read",
                    "Microsoft.Compute/virtualMachineScaleSets/read",
                    "Microsoft.Compute/virtualMachineScaleSets/manualUpgrade/action"
                ],
                "notActions": [],
                "dataActions": [],
                "notDataActions": []
            }
        ]
    }
}

GCP

In Google Cloud is similar to AWS. We will connect from other GCP Projectand you have to bind our Service Account to the desired role in your Projects IAM. An example Policy may contain:

  • compute.autoscalers.get

  • compute.autoscalers.list

  • compute.autoscalers.update

  • compute.healthChecks.get

  • compute.healthChecks.list

  • compute.instanceGroups.get

  • compute.instanceGroups.list

  • compute.instanceGroups.update

  • compute.instances.get

  • compute.instances.list

  • compute.instances.reset

  • compute.instances.start

  • compute.instances.stop

  • compute.instances.suspend

  • compute.nodeGroups.get

  • compute.nodeGroups.list

  • compute.nodeGroups.update

Last updated