Terraform + Netlify + deploy key

Hi,

I would like to lunch terraform inside my project which is served by Netlify. I don’t know what I should type at place with netlify_deploy_key.key.id ? Can someone helps me ?
Thanks

Hi @piotrpietrusewicz, just to be clear, are you asking for your Netlify deploy key for one of your sites? It’s not clear to me what terraform has to do with the netlify deploy key so more details would be helpful. Thank you!

Hi @futuregerald , inside this site https://www.terraform.io/docs/providers/netlify/index.html and inside repo {} is value called deploy_key_id and I can’t figure out what value should be there ?

This value appears to be the Netlify Deploy Key value returns from https://open-api.netlify.com/#operation/createDeployKey

It appears the terraform provider https://www.terraform.io/docs/providers/netlify/r/netlify_deploy_key.html creates that key

Alternatively, outside of TF, here is example of how to create a key via node.js

const fetch = require('node-fetch')

async function createNetlifyDeployKey(config, apiToken) {
  console.log('Creating Netlify deploy key')
  const url = 'https://api.netlify.com/api/v1/deploy_keys/'
  const response = await fetch(url, {
    method: 'POST',
    body: JSON.stringify(config),
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${apiToken}`
    }
  })
  return await response.json()
}
1 Like