Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Consider moving resource meta arguments from generated code to terra pkg #14

@jlarfors

Description

@jlarfors

Currently the Terraform meta arguments, e.g. depends_on, are generated per resource.

Moving these to the terra pkg would make it easier to modify these in the future as it would not require the generated code to be updated.

For example, below is generated code for a resource:

// Resource represents the Terraform resource aws_eks_access_policy_association.
type Resource struct {
	Name      string
	Args      Args
	state     *awsEksAccessPolicyAssociationState
	DependsOn terra.Dependencies
	Lifecycle *terra.Lifecycle
}

This could become:

// Resource represents the Terraform resource aws_eks_access_policy_association.
type Resource struct {
	Name      string
	Args      Args
	state     *awsEksAccessPolicyAssociationState
	// Embed MetaArgs (depends_on, etc.)
	terra.MetaArgs
}

Then in the terra pkg we would have something like:

type MetaArgs struct {
	DependsOn Dependencies
	Lifecycle *Lifecycle
}

// Dependencies returns the list of dependencies for this block.
func (r *MetaArgs) Dependencies() Dependencies {
	return r.DependsOn
}

// LifecycleManagement returns the lifecycle block for this block.
func (r *MetaArgs) LifecycleManagement() *Lifecycle {
	return r.Lifecycle
}

Then the Dependencies() and LifecycleManagement() functions from the generated code could also be removed.

Note that data sources support nearly all the same meta arguments as resources, and so we could re-use the terra.MetaArgs and embed those in data sources. If a user would use some meta args not supported by data sources this would be reported by terraform, so there is little room for error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions