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

DigitalOcean VM creation error #24

Open
0xAnom4ly opened this issue Feb 13, 2025 · 2 comments
Open

DigitalOcean VM creation error #24

0xAnom4ly opened this issue Feb 13, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@0xAnom4ly
Copy link

Hello,

I ran into issue with terraform script erroring out during scan start with DigitalOcean VMs.

I entered API key in providers and filled rest like this:

Image

I also tried filling in tag but error was the same.

Here is Ansible output log of the error:

fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/terraform init -input=false -no-color -backend-config region=eu-central-1 -backend-config bucket=hodororbit -backend-config key=statefile/oa8z4qk9u4e77tm/terraform.tfstate -backend-config access_key=REDACTED -backend-config secret_key=REDACTED", "msg": "\nError: Terraform encountered problems during initialisation, including problems\nwith the configuration, described below.\n\nThe Terraform configuration must be valid before initialization so that\nTerraform can determine which modules and providers need to be installed.\n\n\nError: Invalid resource name\n\n  on digitalocean_do.tf line 1, in resource \"digitalocean_tag\" \"\":\n   1: resource \"digitalocean_tag\" \"\" {\n\nA name must start with a letter or underscore and may contain only letters,\ndigits, underscores, and dashes.\n\nError: Invalid attribute name\n\n  on digitalocean_do.tf line 20, in resource \"digitalocean_droplet\" \"vm\":\n  20:   tags = [digitalocean_tag..id,]\n\nAn attribute name is required after a dot.", "rc": 1, "stderr": "\nError: Terraform encountered problems during initialisation, including problems\nwith the configuration, described below.\n\nThe Terraform configuration must be valid before initialization so that\nTerraform can determine which modules and providers need to be installed.\n\n\nError: Invalid resource name\n\n  on digitalocean_do.tf line 1, in resource \"digitalocean_tag\" \"\":\n   1: resource \"digitalocean_tag\" \"\" {\n\nA name must start with a letter or underscore and may contain only letters,\ndigits, underscores, and dashes.\n\nError: Invalid attribute name\n\n  on digitalocean_do.tf line 20, in resource \"digitalocean_droplet\" \"vm\":\n  20:   tags = [digitalocean_tag..id,]\n\nAn attribute name is required after a dot.\n", "stderr_lines": ["", "Error: Terraform encountered problems during initialisation, including problems", "with the configuration, described below.", "", "The Terraform configuration must be valid before initialization so that", "Terraform can determine which modules and providers need to be installed.", "", "", "Error: Invalid resource name", "", "  on digitalocean_do.tf line 1, in resource \"digitalocean_tag\" \"\":", "   1: resource \"digitalocean_tag\" \"\" {", "", "A name must start with a letter or underscore and may contain only letters,", "digits, underscores, and dashes.", "", "Error: Invalid attribute name", "", "  on digitalocean_do.tf line 20, in resource \"digitalocean_droplet\" \"vm\":", "  20:   tags = [digitalocean_tag..id,]", "", "An attribute name is required after a dot."], "stdout": "Initializing the backend...\n\nSuccessfully configured the backend \"s3\"! Terraform will automatically\nuse this backend unless the backend configuration changes.\n", "stdout_lines": ["Initializing the backend...", "", "Successfully configured the backend \"s3\"! Terraform will automatically", "use this backend unless the backend configuration changes."]}

@ralphte ralphte self-assigned this Feb 13, 2025
@ralphte ralphte added the bug Something isn't working label Feb 13, 2025
@ralphte
Copy link
Contributor

ralphte commented Feb 13, 2025

Thanks for reporting this. It was a template issue in ansible and it is fixed. Fix below. In the next taged version this will not be a issue. But for now just add one tag and it will work.

{% if vm.tags and vm.tags.strip() %} {% for tag in vm.tags.split(',') %} resource "digitalocean_tag" "{{ tag | trim | lower | replace(' ', '_') }}" { name = "{{ tag | trim }}" } {% endfor %} {% endif %}

@0xAnom4ly
Copy link
Author

Thanks, I edited the template and it works if you provide a tag. If you don't, it still errors out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants