# Organization-scoped resources

Config Connector can manage your resources at the project, folder, or
organization level. In order for Config Connector to determine where to create
your resources, it first checks for a [scope-defining field](https://docs.cloud.google.com/config-connector/docs/how-to/organizing-resources/overview#scope-defining_field)
in your resource spec, if not found, then checks for a [scope-defining annotation](https://docs.cloud.google.com/config-connector/docs/how-to/organizing-resources/overview#scope-defining_annotation).

> [!NOTE]
> **Note:** The scope concept does not apply to all Config Connector resources. See [Exceptions](https://docs.cloud.google.com/config-connector/docs/how-to/organizing-resources/overview#exceptions) for more details. You can check the [resource reference page](https://docs.cloud.google.com/config-connector/docs/reference/resources) to see if a resource supports the `spec.organizationRef` field or `cnrm.cloud.google.com/organization-id` annotation.

## Specify `organizationRef` field

Most organization-scoped Config Connector resources support a field named `organizationRef`
in its CRD spec. Use this field to specify the Google Cloud organization that you
want to create the resource in.

You can use the `external` field to specify the organization ID. The exact
format of the value may be different depending on the resource type. Two most
common formats are "<var translate="no">ORGANIZATION_ID</var>" and
"organizations/<var translate="no">ORGANIZATION_ID</var>".
See an example of "<var translate="no">ORGANIZATION_ID</var>" below:

    ...
    spec:
      organizationRef:
        external: "ORGANIZATION_ID"
    ...

## Annotate resource configuration

If the Config Connector resource is organization-scoped but does not support
`organizationRef` field, you can set the organization ID to the resource configuration
using the `organization-id` annotation:

    ...
    metadata:
      annotations:
        cnrm.cloud.google.com/organization-id: ORGANIZATION_ID
    ...

The following example shows what a resource's YAML configuration looks like with
this annotation:

    apiVersion: SERVICE_NAME.cnrm.cloud.google.com/v1beta1
    kind: RESOURCE_KIND
    metadata:
      annotations:
        cnrm.cloud.google.com/organization-id: ORGANIZATION_ID
      name: RESOURCE_NAME

Replace the following:

- `SERVICE_NAME`: the Google Cloud service name for the resource
- `RESOURCE_KIND`: the kind of the Config Connector resource
- `ORGANIZATION_ID`: your Google Cloud organization ID
- `RESOURCE_NAME`: the name of the resource

## Annotate namespace configuration

You can set a default organization ID for newly-created resources by
annotating your Kubernetes namespace. If any of the resources in the namespace
have this annotation explicitly set in its own configuration, the resource level
annotation overwrites the namespace-level annotation.

To annotate the namespace using command line, run the following command:

```
kubectl annotate namespace NAMESPACE_NAME cnrm.cloud.google.com/organization-id=ORGANIZATION_ID
```

Replace the following:

- `NAMESPACE_NAME`: your namespace name
- `ORGANIZATION_ID`: your Google Cloud organization ID

Alternatively, you can apply a YAML manifest containing the annotation.
Copy the YAML below into a file:

    apiVersion: v1
    kind: Namespace
    metadata:
      annotations:
        cnrm.cloud.google.com/organization-id: ORGANIZATION_ID
      name: NAMESPACE_NAME

Replace the following:

- `ORGANIZATION_ID`: your Google Cloud organization ID
- `NAMESPACE_NAME`: your namespace name

After you have created the file, apply it to your cluster.

> [!NOTE]
> **Note:** You must create the namespace and annotation before applying any resources into the namespace.