Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to create IBM Cloud Functions Action #837

Closed
gary1998 opened this issue Nov 4, 2019 · 14 comments
Closed

Not able to create IBM Cloud Functions Action #837

gary1998 opened this issue Nov 4, 2019 · 14 comments
Assignees

Comments

@gary1998
Copy link
Contributor

gary1998 commented Nov 4, 2019

Here is the .tf file:

provider "ibm" {
  ibmcloud_api_key    = "XXXXXXXXXXXXXXXX"
}

# Create an instance of an IBM service
resource "ibm_service_instance" "service" {
  name       = "tf-service"
  space_guid = "${data.ibm_space.space.id}"
  service    = "speech_to_text"
  plan       = "lite"
  tags       = ["cluster-service", "cluster-bind"]
}

# Create a Cloud Functions action
resource "ibm_function_action" "nodehello" {
  name = "action-name"
  exec = {
    kind = "nodejs:6"
    code = "${file("hellonode.js")}"
  }
}

After issuing terraform apply along with setting env variable FUNCTION_NAMESPACE, response is:

gauravs-mbp:terraform_proj gauravgoswami$ terraform apply
data.ibm_space.space: Refreshing state...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + ibm_function_action.nodehello
      id:                       <computed>
      annotations:              <computed>
      exec.#:                   "1"
      exec.0.code:              "console.log(\"HELLO\");"
      exec.0.kind:              "nodejs:6"
      limits.#:                 <computed>
      name:                     "action-name"
      parameters:               <computed>
      user_defined_annotations: "[]"
      user_defined_parameters:  "[]"
      version:                  <computed>

  + ibm_service_instance.service
      id:                       <computed>
      credentials.%:            <computed>
      name:                     "tf-service"
      plan:                     "lite"
      service:                  "speech_to_text"
      service_keys.#:           <computed>
      service_plan_guid:        <computed>
      space_guid:               "96b450b0-2713-45eb-a454-4e20d8128ff0"
      tags.#:                   "2"
      tags.1312709308:          "cluster-bind"
      tags.1867880919:          "cluster-service"
      wait_time_minutes:        "10"

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ibm_service_instance.service: Creating...
  credentials.%:     "" => "<computed>"
  name:              "" => "tf-service"
  plan:              "" => "lite"
  service:           "" => "speech_to_text"
  service_keys.#:    "" => "<computed>"
  service_plan_guid: "" => "<computed>"
  space_guid:        "" => "96b450b0-2713-45eb-a454-4e20d8128ff0"
  tags.#:            "" => "2"
  tags.1312709308:   "" => "cluster-bind"
  tags.1867880919:   "" => "cluster-service"
  wait_time_minutes: "" => "10"
ibm_function_action.nodehello: Creating...
  annotations:              "" => "<computed>"
  exec.#:                   "" => "1"
  exec.0.code:              "" => "console.log(\"HELLO\");"
  exec.0.kind:              "" => "nodejs:6"
  limits.#:                 "" => "<computed>"
  name:                     "" => "action-name"
  parameters:               "" => "<computed>"
  user_defined_annotations: "" => "[]"
  user_defined_parameters:  "" => "[]"
  version:                  "" => "<computed>"
ibm_service_instance.service: Still creating... (10s elapsed)
ibm_service_instance.service: Still creating... (20s elapsed)
ibm_service_instance.service: Still creating... (30s elapsed)
ibm_service_instance.service: Creation complete after 32s (ID: 8dd749cf-5358-4bbb-a4ae-4f2469e2824e)

Error: Error applying plan:

1 error occurred:
    * ibm_function_action.nodehello: 1 error occurred:
    * ibm_function_action.nodehello: Namespace is (), it must be of the form <org>_<space>, provider can't find the auth key if you use _ as well

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Then, tried with declaring namespace within the provider block of .tf file and this was the response:
Gauravs-MacBook-Pro:terraform_proj gauravgoswami$ terraform apply
data.ibm_space.space: Refreshing state...
ibm_service_instance.service: Refreshing state... (ID: c06fadb6-72c1-4408-afbc-a5e6f273ae09)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + ibm_function_action.nodehello
      id:                       <computed>
      annotations:              <computed>
      exec.#:                   "1"
      exec.0.code:              "console.log(\"HELLO\");"
      exec.0.kind:              "nodejs:6"
      limits.#:                 <computed>
      name:                     "action-name"
      parameters:               <computed>
      user_defined_annotations: "[]"
      user_defined_parameters:  "[]"
      version:                  <computed>

  + ibm_service_instance.service
      id:                       <computed>
      credentials.%:            <computed>
      name:                     "tf-service"
      plan:                     "lite"
      service:                  "speech_to_text"
      service_keys.#:           <computed>
      service_plan_guid:        <computed>
      space_guid:               "96b450b0-2713-45eb-a454-4e20d8128ff0"
      tags.#:                   "2"
      tags.1312709308:          "cluster-bind"
      tags.1867880919:          "cluster-service"
      wait_time_minutes:        "10"

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ibm_service_instance.service: Creating...
  credentials.%:     "" => "<computed>"
  name:              "" => "tf-service"
  plan:              "" => "lite"
  service:           "" => "speech_to_text"
  service_keys.#:    "" => "<computed>"
  service_plan_guid: "" => "<computed>"
  space_guid:        "" => "96b450b0-2713-45eb-a454-4e20d8128ff0"
  tags.#:            "" => "2"
  tags.1312709308:   "" => "cluster-bind"
  tags.1867880919:   "" => "cluster-service"
  wait_time_minutes: "" => "10"
ibm_function_action.nodehello: Creating...
  annotations:              "" => "<computed>"
  exec.#:                   "" => "1"
  exec.0.code:              "" => "console.log(\"HELLO\");"
  exec.0.kind:              "" => "nodejs:6"
  limits.#:                 "" => "<computed>"
  name:                     "" => "action-name"
  parameters:               "" => "<computed>"
  user_defined_annotations: "" => "[]"
  user_defined_parameters:  "" => "[]"
  version:                  "" => "<computed>"
ibm_service_instance.service: Still creating... (10s elapsed)
ibm_service_instance.service: Still creating... (20s elapsed)
ibm_service_instance.service: Creation complete after 25s (ID: a30d79ad-49ed-4d7f-b604-f02708644bb7)

Error: Error applying plan:

1 error occurred:
	* ibm_function_action.nodehello: 1 error occurred:
	* ibm_function_action.nodehello: Couldn't retrieve auth key for IBM Cloud Function

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Both ways, the speech to text service was created successfully, but the functions action was not created.


Gauravs-MacBook-Pro:terraform_proj gauravgoswami$ terraform version
Terraform v0.11.14
+ provider.ibm v0.18.0
hkantare added a commit to hkantare/terraform-provider-ibm that referenced this issue Nov 7, 2019
hkantare added a commit that referenced this issue Nov 7, 2019
@itraveribon
Copy link

I am having the same problem. Is there a way to create ibm cloud functions with terraform?

@davetropeano
Copy link
Collaborator

davetropeano commented May 27, 2020 via email

@itraveribon
Copy link

Hi @davetropeano,

thanks for your answer. Is supporting Cloud Functions API Gateway a planned feature or is it out of the scope for now?

Regards

@davetropeano
Copy link
Collaborator

I'll let the provider dev team answer. It's in their backlog but I don't think it is a short term item.

@hkantare
Copy link
Collaborator

We are working to support both IAM and CF enabled namespaces
We will update once we done with development support

@pheuberger
Copy link

Will support for APIGW be rolled out as well @hkantare?

@hkantare
Copy link
Collaborator

Our initial release

  1. make the existing resources to support for CF and IAM based namesapce
  2. Resource support to create namespace
  3. Support for API GW (not yet planned)

@MohdUmar20
Copy link

@hkantare : When we can expect that Cloud function with IAM based Namespace will be supported in terraform and also the creation of namespace as well ?

@hkantare
Copy link
Collaborator

In couple of days we are planning a release support for make the existing resources for CF and IAM based namesapce
Mostly by this weekend we will have a release planned

@hkantare
Copy link
Collaborator

https://github.com/IBM-Cloud/terraform-provider-ibm/releases/tag/v1.9.0

This release support creating the cloud functions for both CF and IAM namespace

@ShoSuenaga
Copy link

ShoSuenaga commented Nov 6, 2020

@hkantare
I have the same problem with v1.14.0.
It seems the creation does not work in regions where Cloud Foundry instances don't exist.
I tried creating an action with the same .tf file except for the region, which succeeded in us-south and failed in jp-tok.
I think that's because setupOpenWhiskClientConfig expects to can get the UAAAccessToken always.

@ShoSuenaga
Copy link

@hkantare
Would it be better if I open a new issue?

@anilkumarnagaraj
Copy link
Collaborator

This issue has been fixed. Did you try with the latest release?

@ShoSuenaga
Copy link

Thank you for your reply.
I just tried the latest version.
It works fine!

@hkantare hkantare closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants