create new apigee product for different environments from CICD

@ssvaidyanathan & Team,

I am looking to create apigee products from CICD pipeline, I have created new folder (resources/org) and created apiproducts.json file and this json file updated with   below mentioned details. if deploy from pipeline I could see all environment apigee product is updating with same details. but our requirement is every environment has different quota limit, quota unit , etc...

Can some one please suggest how can we achieve this from CICD

 

[
{
"name": "apigee-poc_product",
"displayName": "apigee-poc_product",
"description": "apigee-poc_product",
"apiResources": [
"/**",
"/"
],
"approvalType": "auto",
"attributes": [
{
"name": "description",
"value": "apigee-poc_product"
},
{
"name": "developer.quota.limit",
"value": "100"
},
{
"name": "developer.quota.interval",
"value": "1"
},
{
"name": "developer.quota.timeunit",
"value": "month"
}
],
"environments": [
"env-name"
],
"proxies": [
"proxy-name"
],
"quota": "100",
"quotaInterval": "1",
"quotaTimeUnit": "month",
"scopes": []
}
]

Solved Solved
0 7 358
1 ACCEPTED SOLUTION

@Laxmman - you will then need to configure different Products for each environment if you want the Quota to come from the API Product config. 

Or else you can configure those values in KVM and then in your proxy refer to it from KVM. With that you will not need any Quota config in the API Product. You can control all the values using KVM and it will pick it depending on the environment

View solution in original post

7 REPLIES 7

@Laxmman - you will then need to configure different Products for each environment if you want the Quota to come from the API Product config. 

Or else you can configure those values in KVM and then in your proxy refer to it from KVM. With that you will not need any Quota config in the API Product. You can control all the values using KVM and it will pick it depending on the environment

Thanks for response @ssvaidyanathan, I would like go with create different apiproduct option so that i can track the quota changes from git repo.

as per your suggestion, if create one apiproduct.json file for each env. How can I call these different type of apiproduct.json(Like devprodct.json, qaproduct.json) file from pipeline based on environment.

this command i am using for deploy apiproduct     

mvn apigee-config:apiproducts -P$(APIGEE_PROFILE) -Dorg=$(APIGEE_ORG) -Dfile=$(mySecureFile.secureFilePath)

There are a few options

1) You can use the maven-replacer plugin and configure it in your pom to replace certain tokens within your json file and replace that.

2) The other option is to create three different JSON files like

dev-apiproducts.json
test-apiproducst.json
prod-apiproducts.json

And in the json file you can just have the apiproduct config like below

 

{
  "version": "1.0",
  "orgConfig": {
    "apiProducts": [
      {
        "name": "EchoProduct-legacy",
        "apiResources": [
          "/",
          "/**"
        ],
        "approvalType": "auto",
        "attributes": [
          {
            "name": "description",
            "value": "Echo Product Legacy"
          },
          {
            "name": "access",
            "value": "public"
          }
        ],
        "description": "Echo Product Legacy",
        "displayName": "Echo Product Legacy",
        "environments": [
          "dev"
        ],
        "proxies": [
          "HelloWorld"
        ],
        "quota": "10000",
        "quotaInterval": "1",
        "quotaTimeUnit": "month",
        "scopes": []
      }
    ]
  }
}

 

and then in the mvn command you can provide the file in your pipeline, like

 

mvn apigee-config:apiproducts -P$(APIGEE_PROFILE) -Dorg=$(APIGEE_ORG) -Dfile=$(mySecureFile.secureFilePath) -Dapigee.config.file=dev-apiproducts.json

 

If the profile matches the env name you can also change it to 

 

mvn apigee-config:apiproducts -P$(APIGEE_PROFILE) -Dorg=$(APIGEE_ORG) -Dfile=$(mySecureFile.secureFilePath) -Dapigee.config.file=$(APIGEE_PROFILE)-apiproducts.json

 

 

@ssvaidyanathan 

I have created multiple files and executed below mentioned command but maven plugin looking for existing apiprodcut file 

error: 

Config file org\apiProducts.json not found

 

mvn apigee-config:apiproducts -P$(APIGEE_PROFILE) -Dorg=$(APIGEE_ORG) -Dfile=$(mySecureFile.secureFilePath) -Dapigee.config.file=dev-apiproducts.json

 I updated pom.xml file also

<includes>
<include>openapi/currency-v1.yaml</include>
<include>apiproxy/proxies/default.xml</include>
<include>apiproxy/proxies/loggly.xml</include>
<include>apiproxy/currency-v1.xml</include>
<include>resources/edge/org/dev-apiproducts.json</include>
<include>resources/edge/org/qa-apiproducts.json</include>
<include>test/integration/test-config.json</include>

Probably you are passing the apigee.config.dir option too. If it is not in the command line. Check in your profile in the pom.xml

@ssvaidyanathan Thanks for your time 

i did not pass the apigee.config.dir option from command line but this option added in my pom.xml file. 

now i removed  <apigee.config.dir>./target/resources/edge</apigee.config.dir> and executed the command, I am getting different error now 

Failed to execute goal com.apigee.edge.config:apigee-config-maven-plugin:2.4.0:keyvaluemaps (create-config-keyvaluemaps) on project apigee-test: config file edge.json or config file not found

I wont be able to support you for every issue like this buddy! You will need to debug too. 

If you are running mvn install or other config you need the directory so pass that in the command line. For API products dont pass apigee.config.dir

For all other config pushes, you need to pass apigee.config.dir