Skip to content

Conversation

crmne
Copy link

@crmne crmne commented Aug 9, 2025

Summary

This PR adds import functionality to the ForwardEmail Terraform provider, allowing users to import existing domains and aliases into their Terraform state.

Changes

  • Added ImportState support to domain resources using passthrough context
  • Added custom import function for alias resources with "domain/alias" format
  • Set name field during Read operations to properly support import state

Usage Examples

Import a domain

terraform import forwardemail_domain.example "example.com"

Import an alias

terraform import forwardemail_alias.example "example.com/alias-name"
# For catch-all aliases:
terraform import forwardemail_alias.catchall "example.com/*"

Testing

Successfully tested importing:

  • Multiple domains
  • Regular aliases (e.g., hello@domain.com)
  • Catch-all aliases (*@domain.com)
  • Aliases with labels and recipient verification settings

All imports correctly populated the Terraform state with the proper configuration from the ForwardEmail API.

Motivation

Without import support, users with existing ForwardEmail configurations cannot adopt Terraform management without recreating all their resources, which would cause service disruption.

🤖 Generated with Claude Code

- Add ImportState support to domain resources using passthrough
- Add custom import function for alias resources with "domain/alias" format
- Set name field during Read operations to support import state

This allows existing ForwardEmail resources to be imported into Terraform:
- Domains: terraform import forwardemail_domain.example "example.com"
- Aliases: terraform import forwardemail_alias.example "example.com/alias"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds import support for domains and aliases in the ForwardEmail Terraform provider, enabling users to manage existing resources without recreating them.

  • Added ImportState support to domain resources using passthrough context
  • Added custom import function for alias resources with "domain/alias" format parsing
  • Set name field during Read operations to properly support import state

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
forwardemail/resource_forwardemail_domain.go Adds import support with passthrough context and sets name field in Read operation
forwardemail/resource_forwardemail_alias.go Adds custom import function with domain/alias parsing and sets name field in Read operation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@crmne crmne requested a review from RoseSecurity September 29, 2025 12:42
Copy link
Collaborator

@RoseSecurity RoseSecurity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks again for this contribution. @crmne Would you be able to add an import.sh and import-by-string-id.tf in the examples directory to show how to use this functionality and regenerate the documentation for the registry using: task docs?
Here is a reference

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

Successfully merging this pull request may close these issues.

2 participants