# Global plugin notation in kong.yml

**URL:** <https://discuss.konghq.com/t/global-plugin-notation-in-kong-yml/4732>\
**Category:** Questions\
**Created:** [October 25, 2019, 1:15pm UTC](https://discuss.konghq.com/t/global-plugin-notation-in-kong-yml/4732 "2019-10-25T13:15:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddysTime](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@eddysTime](https://discuss.konghq.com/u/eddysTime)\
**Post date:** [October 25, 2019, 1:15pm UTC](https://discuss.konghq.com/t/global-plugin-notation-in-kong-yml/4732/1 "2019-10-25T13:15:44Z")

</div>

Hi guys,

I am running into an issue while trying to write a kong.yml to run kong in db less mode. Generally the configuration file is working. I’ve tried it with a simple service following [this](https://medium.com/@matias_azucas/db-less-kong-tutorial-8cbf8f70b266) article. Now I want to dive deeper into the configuration file by migrating my other services, routes, plugins.

```
    plugins:
  - name: cors
    config:
      - origins:
          - '*'
        methods:
          - GET
          - HEAD
          - PUT
          - PATCH
          - POST
          - DELETE
        headers:
          - Origin
          - Accept
          - Content-Type
          - X-Auth-Token
          - Authorization
          - X-Userinfo
          - X-Access-Token
          - X-Id-Token
        max_age: 3600
        preflight_continue: false

```

Above you can see a part of my kong.yml which I am using to create a global plugin. After I added the configuration file to my kong container and started the container I received the following error message:

2019/10/25 13:09:48 [error] 1#0: init\_by\_lua error: /usr/local/share/lua/5.1/kong/init.lua:382: error parsing declarative config file kong.yml:  
kong\_1 | in ‘plugins’:  
kong\_1 | - in entry 1 of ‘plugins’:  
kong\_1 | in ‘config’:  
kong\_1 | - in entry 1 of ‘config’: unknown field

After reading the error message the error can be simply identified by a wrong field declaration.

So my question is what the appropriate notation or appropriate field name would be to define a global plugin in my kong.yml with some configurations?

Down below you can find my complete kong.yml. The only changes I did to the original yaml before sharing it here is swapping the Host-IP with localhost.

Any help is highly appreciated!

Kind regards,  
eddysTime

```
_format_version: '1.1'

services:
  - name: test-service
    url: http://localhost:5555
    path: /
    plugins:
      - name: prometheus
    routes:
      - name: test-route
        paths:
          - /pepsi
        strip_path: false
        methods:
          - GET
          - POST
          - OPTIONS
  - name: botframework-service
    url: http://localhost:9000
    path: /api/sendRequest/botframework
    plugins:
      - name: prometheus
    routes:
      - name: botframework-route
        paths:
          - /bot
        strip_path: true
        methods:
          - GET
  - name: coke-service
    url: http://localhost:5555
    path: /
    routes:
      - name: coke-route
        paths:
          - /coke
        strip_path: false
        methods:
          - GET
          - POST
          - OPTIONS

plugins:
  - name: cors
    configs:
      - origins:
          - '*'
        methods:
          - GET
          - HEAD
          - PUT
          - PATCH
          - POST
          - DELETE
        headers:
          - Origin
          - Accept
          - Content-Type
          - X-Auth-Token
          - Authorization
          - X-Userinfo
          - X-Access-Token
          - X-Id-Token
        max_age: 3600
        preflight_continue: false
  - name: oidc
    configs:
      - client_id: kong
        client_secret: '5fd50a43-8654-4726-aae3-83b2c4468fe5'
        discovery: http://localhost:8180/auth/realms/master/.well-known/openid-configuration
        introspection_endpoint: http://localhost:8180/auth/realms/master/protocol/openid-connect/token/introspect
        bearer_only: 'yes'
  - name: prometheus

```

---

<div class="post-metadata">

**Author:** ![Themba\_Mkhize](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/themba_mkhize/32/2209_2.png) [@Themba\_Mkhize](https://discuss.konghq.com/u/Themba_Mkhize)\
**Post date:** [September 8, 2020, 2:40pm UTC](https://discuss.konghq.com/t/global-plugin-notation-in-kong-yml/4732/2 "2020-09-08T14:40:41Z")

</div>

It seems you can only add a plugin to either a service or a route. This is what worked for me:

plugins:

- name: cors  
service: test-service  
config:  
origins:  
- ‘\*’  
methods:  
- GET  
- HEAD  
- PUT  
- PATCH  
- POST  
- DELETE  
- OPTIONS  
headers:  
- Origin  
- Accept  
- Content-Type  
- X-Auth-Token  
- Authorization  
- X-Userinfo  
- X-Access-Token  
- X-Id-Token  
- Access-Control-Allow-Origin  
max\_age: 3600  
preflight\_continue: false

---

<div class="post-metadata">

**Author:** ![vinicius.mignot](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/vinicius.mignot/32/3442_2.png) [@vinicius.mignot](https://discuss.konghq.com/u/vinicius.mignot)\
**Post date:** [September 8, 2020, 11:23pm UTC](https://discuss.konghq.com/t/global-plugin-notation-in-kong-yml/4732/3 "2020-09-08T23:23:55Z")

</div>

You were not able to use the original configuration because there are a few things wrong in your complete kong.yml: `config` is misspelled and `origins` should not begin with `-`.
