-
Notifications
You must be signed in to change notification settings - Fork 10k
Add ephemeral resources to the Terraform language #35728
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
Conversation
baa058c
to
95124db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I left just a few minor questions inline.
var ephemeralBlockSchema = &hcl.BodySchema{ | ||
Attributes: commonResourceAttributes, | ||
Blocks: []hcl.BlockHeaderSchema{ | ||
{Type: "lifecycle"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{Type: "lifecycle"}, | |
{Type: "lifecycle"}, // reserved for future use |
case "precondition", "postcondition": | ||
cr, moreDiags := decodeCheckRuleBlock(block, override) | ||
diags = append(diags, moreDiags...) | ||
|
||
moreDiags = cr.validateSelfReferences(block.Type, r.Addr()) | ||
diags = append(diags, moreDiags...) | ||
|
||
switch block.Type { | ||
case "precondition": | ||
r.Preconditions = append(r.Preconditions, cr) | ||
case "postcondition": | ||
r.Postconditions = append(r.Postconditions, cr) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how much complexity/effort will be required to make conditions work for the new resource type but we could also just reserve these in the language initially. You are more likely to know the answer though, so I'm assuming if you are proposing to keep it like this, it's not too complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from optimistically hoping that the implementation isn't too difficult (these are still just a resource type after all), they also seem useful when the values are not easily extracted by the user for other debugging purposes. If there is any problem implementing later steps we can always reserve the block names to prevent their use. These first commits are all preliminary anyway, there will probably be some changes as all the pieces are integrated.
@@ -18,6 +18,8 @@ import ( | |||
"github.com/hashicorp/terraform/internal/addrs" | |||
"github.com/hashicorp/terraform/internal/depsfile" | |||
"github.com/hashicorp/terraform/internal/getproviders/providerreqs" | |||
|
|||
_ "github.com/hashicorp/terraform/internal/logging" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intentional or was it just to temporarily aid debugging in test environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to import the internal logging package somewhere to initialize the default logger, so any package tested in isolation needs this to not print all logs during tests.
Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
This add ephemeral resources to the configuration language. Terraform can now parse ephemeral resource configuration and references.