Comments (6)
Have a prototype of zone import already working
configuration:
resource "powerdns_zone" "test_com" {
name = "test.com."
kind = "Master"
nameservers = formatlist("%s.", keys(local.pdns_servers))
}
$ terraform import powerdns_zone.test_com '{"name": "test.com."}'
Acquiring state lock. This may take a few moments...
powerdns_zone.test_com: Importing from ID "{\"name\": \"test.com.\"}"...
powerdns_zone.test_com: Import prepared!
Prepared powerdns_zone for import
powerdns_zone.test_com: Refreshing state... [id=test.com.]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
Releasing state lock. This may take a few moments...
ck. This may take a few moments...
powerdns_zone.test_com: Importing from ID "{\"name\": \"test.com.\"}"...
powerdns_zone.test_com: Import prepared!
Prepared powerdns_zone for import
powerdns_zone.test_com: Refreshing state... [id=test.com.]
Import successful!
state show:
terraform state show powerdns_zone.test_com
# powerdns_zone.test_com:
resource "powerdns_zone" "test_com" {
id = "test.com."
kind = "Master"
name = "test.com."
nameservers = [
"pdns-01.test.com.",
"pdns-02.test.com.",
]
}
and a plan after import:
powerdns_zone.test_com: Refreshing state... [id=test.com.]
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
I'll keep working on the same for record resource and will also add tests.
from terraform-provider-powerdns.
since this is deleting any record with an empty rrSet, shouldn't this line be d.SetId("") after a successful delete?
You're right here, but the fix most likely will involve touching other places so I've opened another issue to track this.
from terraform-provider-powerdns.
@dannyk81 Using schema.ImportStatePassthrough
wouldn’t work?
from terraform-provider-powerdns.
@splashx indeed that was my initial attempt, but using schema.ImportStatePassthrough
comes with a challenge: "This function requires the Read function to be able to refresh the entire resource with d.Id() ONLY." https://www.terraform.io/docs/extend/resources/import.html#importer-state-function
-
with the
zone
resource, I believe I have a working solution - however it requires changes to theRead
andExists
methods, I will push this soon for you to take a look at. Edit: additionally, the Read didn't fetch the zone nameservers which are required attribute for the resource, so I'm adding that as well. -
with the
record
resource, this is tricky - since we need both the Zone name and the Record ID to be able to retrieve the RR Set.
from terraform-provider-powerdns.
@splashx just pushed latest changes.
zone
resource usesschema.ImportStatePassthrough
- tests for importing added to both
I think this is ready for a review, let me know what you think 😄
from terraform-provider-powerdns.
@splashx have a question about https://github.com/terraform-providers/terraform-provider-powerdns/blob/3d8c32c5ffe7c6e7932886a86f94d7e51f94eef9/powerdns/resource_powerdns_record.go#L101
since this is deleting any record with an empty rrSet, shouldn't this line be d.SetId("")
after a successful delete?
from terraform-provider-powerdns.
Related Issues (20)
- A function to determine automatically common reverse zones for private address ranges HOT 1
- Consider adding GPG key to opentofu registry
- Nameserver Ammendments Causes Zone recreation HOT 6
- masters attribute doesn't allow to specify port HOT 1
- Add support for LUA records (Feature Request) HOT 2
- The attribute "server_url" is required, but no definition was found. HOT 2
- Issue links in Changelog.md point to the old repo
- SOA details not settable when using powerdns_zone HOT 9
- Incremental 500 internal server errors HOT 8
- Provider forcing replacement of records unnecessairily HOT 1
- Fix failing tests HOT 11
- Records with upper case characters are not destroyed HOT 1
- Update terraform sdk to v2 HOT 5
- Add powerdns configuration API as resources
- [SOLVED] API Adding records unkown database column. HOT 4
- Build provider for Darwin ARM64 (Mac M1) HOT 6
- Remove travis integration
- Request Release HOT 7
- Native tooling for creating reverse ptr records from a given IPv4 or v6 address HOT 1
- How to trigger a NOTIFY when updating records with provider? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-powerdns.