New Terraform provider for Apigee configuration

I have created a new Terraform provider for Apigee:

https://registry.terraform.io/providers/scastria/apigee/latest

As you would expect, it leverages the Apigee Management API to perform all of the underlying work. This provider does not currently support all resource types that the Apigee Management API can handle, but it does offer quite a few. If you would like to know which resource types it does support, there is a Documentation tab at the link above.

If anyone would like to contribute to this provider or offer feedback, please go to the Github source repo here: https://github.com/scastria/terraform-provider-apigee

Here is a small example of what it looks like to create a proxy, deploy proxy, create product, create developer, create developer app, and import custom credential:

resource "apigee_proxy" "MyProxy" {
  name = "MyProxy"
  bundle = "proxies/MyProxy.zip"
  bundle_hash = filebase64sha256("proxies/MyProxy.zip")
}
resource "apigee_proxy_deployment" "MyProxyDeploy" {
  proxy_name = apigee_proxy.MyProxy.name
  environment_name = "dev"
  revision = apigee_proxy.MyProxy.revision
}
resource "apigee_product" "MyProduct" {
  name = "MyProduct"
  display_name = "My Product"
  auto_approval_type = true
  environments = [
    "dev",
    "test",
    "stage"
  ]
  proxies = [
    apigee_proxy.MyProxy.name
  ]
  scopes = [
    "openid",
    "profile"
  ]
}
resource "apigee_developer" "MyDeveloper" {
  email = "Alex.Hamilton@example.com"
  first_name = "Alex"
  last_name = "Hamilton"
  user_name = "ahamilton"
}
resource "apigee_developer_app" "MyApp" {
  developer_email = apigee_developer.MyDeveloper.email
  name = "MyApp"
  attributes = {
    DisplayName = "My App"
  }
}
resource "apigee_developer_app_credential" "MyAppCred" {
  developer_email = apigee_developer.MyDeveloper.email
  developer_app_name = apigee_developer_app.MyApp.name
  consumer_key = "importedKeyValue"
  consumer_secret = "importedSecretValue"
  api_products = [
    apigee_product.MyProduct.name
  ]
}

NOTE: This is NOT intended to help install Apigee OnPrem, but to automate the configuration of Apigee whether in the Public Cloud or OnPrem.

Comments
Not applicable

Can you share any document or link which is good to start with terraform?

shawncastrianni
New Member

I just used the docs from Terraform located here:


https://www.terraform.io/docs/cli-index.html

devajeetbharali
New Member

Can we use for loop to loop around multiple zip files without having to specifically mentioning it inside bundle?

shawncastrianni
New Member

I’m not sure I follow the question. Do you want to use the exact same zip for multiple proxies? Do you want to use different zips for different proxies? I guess your “mentioning it inside the bundle” is the part that confuses me.

devajeetbharali
New Member

Yeah, I want to use different zips for different proxies. As of now, I am copying the same code 6 times (as I need to import 6 proxies) and so I am changing the zip file in the bundle in every code to refer to a particular proxy. Can it be done with for-loop without writing the same code again and again?

shawncastrianni
New Member

If you are copying the same code 6 times, doesn’t that mean you want to use the SAME zip file for each proxy? I assume the only reason you are modifying each copy of the zip is to modify the top level xml file that references the name of the proxy. If this is correct, no, the Apigee provider for TerraForm does not edit the proxy bundle zip file in any way so a for loop would not help you.

Version history
Last update:
‎12-01-2020 04:11 PM
Updated by: