---
layout: "fastly"
page_title: "Fastly: Service Authorization"
sidebar_current: "docs-fastly-resource-service_authorization"
description: |-
  Grants user access to service
---

# service_authorization

Configures authorization with granular permissions to services. Users can be granted rights for services on different levels.

The Service Authorization resource requires a user id, service id and an optional permission.

## Example Usage

Basic usage:

```terraform
resource "fastly_service_vcl" "demo" {
  name = "demofastly"

  domain {
    name    = "demo.notexample.com"
    comment = "demo"
  }
}


resource "fastly_user" "user" {
  login = "demo@example.com"
  name  = "Demo User"
}

resource "fastly_service_authorization" "auth" {
  service_id = fastly_service_vcl.demo.id
  user_id    = fastly_user.user.id
  permission = "purge_all"
}
```

## Import

A Fastly Service Authorization can be imported using their user ID, e.g.

```sh
$ terraform import fastly_service_authorization.demo xxxxxxxxxxxxxxxxxxxx
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `permission` (String) The permissions to grant the user. Can be `full`, `read_only`, `purge_select` or `purge_all`.
- `service_id` (String) The ID of the service to grant permissions for.
- `user_id` (String) The ID of the user which will receive the granted permissions.

### Read-Only

- `id` (String) The ID of this service authorization.
