Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _stacks_generated/.terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.13.5
26 changes: 26 additions & 0 deletions _stacks_generated/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions _stacks_generated/components.tfcomponent.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by tf-migrate 2.0.0-beta1


component "ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"

inputs = {
"ami" = var.ami_id
"instance_type" = var.instance_type
"monitoring" = true
"name" = var.instance_name
"subnet_id" = "subnet-04ac8df91e75657c9"
"tags" = {
Terraform = "true"
Environment = "dev"
}
"vpc_security_group_ids" = []
}

version = "~> 6.0"


providers = {
aws = provider.aws.this
}
}


41 changes: 41 additions & 0 deletions _stacks_generated/deployment.tfdeploy.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by tf-migrate 2.0.0-beta1



# Note on stacks authentication:
# tf-migrate cannot generate stack authentication, this needs to be manually added before execute
# More on authentication - https://developer.hashicorp.com/terraform/language/stacks/deploy/authenticate

store "varset" "tokens" {
id = "varset-xvfRyT1qNahGfpWm"
category = "env"
}

deployment "dev-workspace" {
inputs = {
access_key = store.varset.tokens.AWS_ACCESS_KEY_ID
secret_key = store.varset.tokens.AWS_SECRET_ACCESS_KEY
session_token = store.varset.tokens.AWS_SESSION_TOKEN
ami_id = "ami-0dee22c13ea7a9a67"
instance_name = "stack-v3-test-dev-instance"
instance_type = "t3.micro"
}
import = true
}



deployment "prod-workspace" {
inputs = {
access_key = store.varset.tokens.AWS_ACCESS_KEY_ID
secret_key = store.varset.tokens.AWS_SECRET_ACCESS_KEY
session_token = store.varset.tokens.AWS_SESSION_TOKEN
instance_name = "stack-v3-test-prod-instance"
instance_type = "t3.micro"
ami_id = "ami-0dee22c13ea7a9a67"
}
import = true
}



15 changes: 15 additions & 0 deletions _stacks_generated/outputs.tfcomponent.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by tf-migrate 2.0.0-beta1


output "instance_id" {
description = "The ID of the EC2 instance"
value = component.ec2_instance.id
type = string
}

output "instance_public_ip" {
description = "The public IP address of the EC2 instance"
value = component.ec2_instance.public_ip
type = string
}

19 changes: 19 additions & 0 deletions _stacks_generated/providers.tfcomponent.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by tf-migrate 2.0.0-beta1



provider "aws" "this" {
config {
region = "ap-south-1"
access_key = var.access_key
secret_key = var.secret_key
token = var.session_token
}
}

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.66.0, >= 5.0.0"
}
}
40 changes: 40 additions & 0 deletions _stacks_generated/variables.tfcomponent.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by tf-migrate 2.0.0-beta1


variable "instance_name" {
description = "Name to be used on all resources as prefix"
type = string
default = "example-instance"
}

variable "instance_type" {
description = "The type of instance to start"
type = string
default = "t3.micro"
}

variable "ami_id" {
description = "ID of AMI to use for the instance"
type = string
default = "ami-0dee22c13ea7a9a67" # Amazon Linux 2023 AMI in ap-south-1 (verify this if needed, but using a placeholder/common one is usually okay for templates)
}

variable "access_key" {
description = "AWS access key"
type = string
ephemeral = true
}

variable "secret_key" {
description = "AWS sensitive secret key."
type = string
sensitive = true
ephemeral = true
}

variable "session_token" {
description = "AWS session token."
type = string
sensitive = true
ephemeral = true
}
42 changes: 42 additions & 0 deletions stacks_migration_infra/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions stacks_migration_infra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
terraform {
required_providers {
tfe = {
source = "hashicorp/tfe"
version = ">= 0.67.0"
}
tfmigrate = {
source = "hashicorp/tfmigrate"
version = "2.0.0-beta1"
}
}
}

provider "tfe" {
hostname = var.tfe_hostname
organization = var.organization_name
}

resource "tfe_project" "stack_project" {
name = var.project_name
organization = var.organization_name
}

resource "tfe_stack" "stack" {
name = var.stack_name
project_id = tfe_project.stack_project.id
}

resource "tfmigrate_stack_migration" "stack_migration" {
config_file_dir = var.stacks_config_file_dir
organization = var.organization_name
name = tfe_stack.stack.name
project = tfe_project.stack_project.name
terraform_config_dir = var.terraform_config_dir
workspace_deployment_mapping = var.workspace_deployment_mapping
}
20 changes: 20 additions & 0 deletions stacks_migration_infra/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
output "project_url" {
value = "https://app.terraform.io/app/${var.organization_name}/projects/${tfe_project.stack_project.id}"
}

output "stack_url" {
value = "https://app.terraform.io/app/${var.organization_name}/projects/${tfe_project.stack_project.id}/stacks/${tfe_stack.stack.id}"
}

locals {
stack_deployment_details = (
tfmigrate_stack_migration.stack_migration.migration_hash != "" ?
provider::tfmigrate::decode_stacks_migration_hash_to_json(
tfmigrate_stack_migration.stack_migration.migration_hash
) : null
)
}

output "stack_deployment_details" {
value = local.stack_deployment_details
}
30 changes: 30 additions & 0 deletions stacks_migration_infra/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
variable "organization_name" {
default = "sujay-test-01"
}

variable "tfe_hostname" {
default = "app.terraform.io"
}

variable "project_name" {
default = "stacks-demo-v3"
}

variable "stack_name" {
default = "hello-stacks-v3"
}

variable "stacks_config_file_dir" {
default = "/Users/sujaysamanta/Workspace/Cursor-AI/terraform-stacks-migration-test/stack-terraform-test-v4/fantastic-octo-computing-machine/_stacks_generated"
}

variable "terraform_config_dir" {
default = "/Users/sujaysamanta/Workspace/Cursor-AI/terraform-stacks-migration-test/stack-terraform-test-v4/fantastic-octo-computing-machine"
}

variable "workspace_deployment_mapping" {
default = {
dev-workspace = "dev-workspace"
prod-workspace = "prod-workspace"
}
}