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

Invalid Index errors #1

Closed
ratkosomni opened this issue Mar 22, 2022 · 13 comments
Closed

Invalid Index errors #1

ratkosomni opened this issue Mar 22, 2022 · 13 comments

Comments

@ratkosomni
Copy link

Is there a way to edit stack variables in order to resolve the 2 errors below?

Error: Invalid index
on network.tf line 108, in resource "oci_core_route_table_attachment" "cn_sftp_lb_subnet_rt_attachment"
108: route_table_id = oci_core_route_table.cn_sftp_lb_subnet_rt[0].id
├────────────────
│ oci_core_route_table.cn_sftp_lb_subnet_rt is empty tuple
The given key does not identify an element in this collection value.

Error: Invalid index
on network.tf line 130, in resource "oci_core_route_table_attachment" "cn_sftp_servers_subnet_rt_attachment"
130: route_table_id = oci_core_route_table.cn_sftp_servers_subnet_rt[0].id
├────────────────
│ oci_core_route_table.cn_sftp_servers_subnet_rt is empty tuple
The given key does not identify an element in this collection value.

@cdivita
Copy link
Collaborator

cdivita commented Mar 22, 2022

Hello,

are you using OCI Resource Manager or are you running the module through Terraform ?

In the latter case, can you share your terraform.tfvars ?

@ratkosomni
Copy link
Author

Hi, thanks for responding. I'm using OCI Resource Manager. The "Deploy" button didn't work for me due to the url being gone so I downloaded the zip file of the latest release, uploaded it to a new stack in Resource Manager, edited my variables, ran a "Plan" and got the 2 errors.

@cdivita
Copy link
Collaborator

cdivita commented Mar 22, 2022

The URL used by Deploy to Oracle Cloud was broken, the right URL is:

https://cloud.oracle.com/resourcemanager/stacks/create?region=home&zipUrl=https://github.com/oracle-quickstart/oci-cloud-native-sftp/releases/latest/download/oci-cloud-native-sftp-stack-latest.zip

The README.md has been updated accordingly, would you try again ?

@ratkosomni
Copy link
Author

Using the new link was helpful (thank you!), but the build still fails with the exact same 2 error messages as above.

@cdivita
Copy link
Collaborator

cdivita commented Mar 22, 2022

Are you using existing subnets, right ?

@cdivita
Copy link
Collaborator

cdivita commented Mar 23, 2022

@ratkosomni the issue was caused by wrong route table attachment when existing subnets are used. Since the subnets are already there, route tables are not created so their attachment should be skipped.

Now is it possible to run terraform plan successfully for both scenarios (non-existing and existing subnets), also using OCI Resource Manager.

@ratkosomni
Copy link
Author

ratkosomni commented Mar 23, 2022

Plan is now able to execute successfully, then attempting to run Apply using the successful Plan output fails.
But even with the "failed" response, it did create the compute instance, load balancer, and OS bucket. Looks like fail errors are related to being unable to set up another NAT Gateway (we have 1 already) and something about the user key (it didn't create a user that I can see). Maybe I can use the components that were successfully provisioned and handle these couple of failed items manually somehow? I may have been mistaken in thinking if we had a NAT gateway already that we wouldn't need a second one created, but we don't have an explicit NAT limit set up in our tenancy so I am not sure why it hit a limit that doesn't exist.

Error: can not marshal to path in request for field UserId. Due to can not marshal a nil pointer
with oci_identity_customer_secret_key.cn_sftp_customer_secret_key,
on customer_secret_key.tf line 1, in resource "oci_identity_customer_secret_key" "cn_sftp_customer_secret_key"
1: resource "oci_identity_customer_secret_key" "cn_sftp_customer_secret_key" {

Error: 400-LimitExceeded
Provider version: 4.68.0, released on 2022-03-17.
Service: Core Nat Gateway
Error Message: NAT gateway limit per VCN reached
OPC request ID: 8694059376d294145f40cbe79d9fa408/D9721261977FB325CF13010CB78BA250/2C9CF94BD8371A815DBBF5749C2A1C16
Suggestion: Request a service limit increase for this resource Core Nat Gateway
with oci_core_nat_gateway.cn_sftp_nat_gw[0],
on network.tf line 28, in resource "oci_core_nat_gateway" "cn_sftp_nat_gw"
28: resource "oci_core_nat_gateway" "cn_sftp_nat_gw" {

@cdivita
Copy link
Collaborator

cdivita commented Mar 23, 2022

There cannot be more than one NAT Gateway for VCN, the error message is not clear. However, since existing VCN and subnets have been selected this action should not be in the plan: issue #2 has been created to fix it.

For using Object Storage through S3 Compatibility API, a customer secret key is required. The stack handles it using the pre-populated variables using Resource Manager, however the name of the variable that contains the user OCID changed recently: issue #3 has been created to fix it

@ratkosomni
Copy link
Author

Thank you for both fixes. Should I destroy the stack and re-run a Plan+Apply?

@cdivita
Copy link
Collaborator

cdivita commented Mar 23, 2022

Thank you for both fixes. Should I destroy the stack and re-run a Plan+Apply?

Yes, please

@ratkosomni
Copy link
Author

Plan and Apply both ran successfully, thank you for your help! This was exactly what my org needed to quickly get an sftp server up and running on our cloud tenancy, can say enough how much I appreciate it.

@moisesdasilvadeoliveira

Hey cdvita,

I'm having the same problem.

Error OCI
022/06/21 16:09:27 [[INFO]] Terraform has been successfully initialized!
2022/06/21 16:09:27 [[INFO]]
2022/06/21 16:09:27 [[INFO]] You may now begin working with Terraform. Try running "terraform plan" to see
2022/06/21 16:09:27 [[INFO]] any changes that are required for your infrastructure. All Terraform commands
2022/06/21 16:09:27 [[INFO]] should now work.
2022/06/21 16:09:27 [[INFO]]
2022/06/21 16:09:27 [[INFO]] If you ever set or change modules or backend configuration for Terraform,
2022/06/21 16:09:27 [[INFO]] rerun this command to reinitialize your working directory. If you forget, other
2022/06/21 16:09:27 [[INFO]] commands will detect it and remind you to do so if necessary.
2022/06/21 16:09:30 [[INFO]]
2022/06/21 16:09:30 [[INFO]] Error: Invalid index
2022/06/21 16:09:30 [[INFO]]
2022/06/21 16:09:30 [[INFO]] on servers.tf line 21, in resource "oci_core_instance" "cn_sftp_servers"
2022/06/21 16:09:30 [[INFO]] 21: availability_domain = data.oci_identity_availability_domains.ads.availability_domains[count.index % (length(data.oci_identity_availability_domains.ads.availability_domains) - 1)].name
2022/06/21 16:09:30 [[INFO]] ├────────────────
2022/06/21 16:09:30 [[INFO]] │ count.index is 1
2022/06/21 16:09:30 [[INFO]] │ data.oci_identity_availability_domains.ads.availability_domains is list of object with 1 element

Terraform Line
availability_domain = data.oci_identity_availability_domains.ads.availability_domains[count.index % (length(data.oci_identity_availability_domains.ads.availability_domains) - 1)].name

Can you help me? I'm using OCI Resource Manager

@cdivita
Copy link
Collaborator

cdivita commented Jun 21, 2022

Let's discuss in the dedicated issue

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

3 participants