# 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

&#x20;

### AWS

We use remote roles to connect to Accounts and manage the desired resources ([best Security Practice](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-workloads-use-roles)). 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&#x20;
* compute.autoscalers.list&#x20;
* compute.autoscalers.update&#x20;
* compute.healthChecks.get&#x20;
* compute.healthChecks.list&#x20;
* compute.instanceGroups.get&#x20;
* compute.instanceGroups.list&#x20;
* compute.instanceGroups.update&#x20;
* compute.instances.get&#x20;
* compute.instances.list&#x20;
* compute.instances.reset&#x20;
* compute.instances.start&#x20;
* compute.instances.stop&#x20;
* compute.instances.suspend&#x20;
* compute.nodeGroups.get&#x20;
* compute.nodeGroups.list&#x20;
* compute.nodeGroups.update


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudplans.io/organization/credentials.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
