# Connect From Config

In order to work with an OpenStack cloud you first need to create a `Connection` to it using your credentials. A `Connection` can be created in 3 ways, using the class itself (see Connect), a file, or environment variables as illustrated below. The SDK uses os-client-config to handle the configuration.

## Create Connection From A File

### Default Location

To create a connection from a file you need a YAML file to contain the configuration.

    clouds:
      devstack:
        auth:
          auth_url: http://xxx.xxx.xxx.xxx/identity
          password: password
          project_domain_id: default
          project_name: demo
          user_domain_id: default
          username: demo
        identity_api_version: '3'
        region_name: RegionOne
        volume_api_version: '3'
      devstack-admin:
        auth:
          auth_url: http://xxx.xxx.xxx.xxx/identity
          password: password
          project_domain_id: default
          project_name: admin
          user_domain_id: default
          username: admin
        identity_api_version: '3'
        region_name: RegionOne
        volume_api_version: '3'
      devstack-alt:
        auth:
          auth_url: http://xxx.xxx.xxx.xxx/identity
          password: password
          project_domain_id: default
          project_name: alt_demo
          user_domain_id: default
          username: alt_demo
        identity_api_version: '3'
        region_name: RegionOne
        volume_api_version: '3'
    example:
      image_name: cirros-0.5.2-x86_64-disk
      flavor_name: m1.small

To use a configuration file called `clouds.yaml` in one of the default locations:

- Current Directory

- ~/.config/openstack

- /etc/openstack

call `from_config()`. The `from_config` function takes three optional arguments:

- cloud_name allows you to specify a cloud from your `clouds.yaml` file.

- cloud_config allows you to pass in an existing `openstack.config.loader.OpenStackConfig`` object.

- options allows you to specify a namespace object with options to be added to the cloud config.

Note

To enable logging, set `debug=True` in the `options` object.

### User Defined Location

To use a configuration file in a user defined location set the environment variable `OS_CLIENT_CONFIG_FILE` to the absolute path of a file.:

    export OS_CLIENT_CONFIG_FILE=/path/to/my/config/my-clouds.yaml

and call `from_config()` with the cloud_name of the cloud configuration to use, .

## Next

Now that you can create a connection, continue with the User Guides for an OpenStack service.

this page last updated: 2026-01-16 23:06:19

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.