Cookie Consent by Free Privacy Policy Generator 📌 How to Temporarily Remove and Reintegrate Cloud Resources from Terraform Management


✅ How to Temporarily Remove and Reintegrate Cloud Resources from Terraform Management


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Recently, I've set up ECS on Fargate and ELB (ALB). Generally, resources are managed through Terraform code. However, ECS task definitions and services require updates with each deployment (due to their short lifecycle), so I manage these using the open-source tool ecspresso.

Encountering a Challenge with ELB Configuration

I initially thought that once an ELB is built, it rarely needs updates. But after introducing Blue/Green deployments, I discovered that the target groups in the listener rules change with each deployment. This leads to discrepancies between the Terraform configuration files and the actual resources, causing issues when creating or updating other resources.

To address this issue, I first considered dynamically loading target groups. However, I felt that this approach would complicate the Terraform configuration. Instead, I opted to temporarily remove the frequently updated resources from Terraform's management and reintegrate them as needed.

Procedure to Remove Resources from Terraform Management

Consider the following listener rule managed in modules/elb/main.tf:

resource "aws_lb_listener_rule" "blue" {
  listener_arn = aws_lb_listener.https_443.arn
  priority     = 100

  action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.target_blue.arn
  }

  condition {
    host_header {
      values = ["dev.example.jp"]
    }
  }
}

Execute the following command in the directory where you perform terraform apply to remove this listener rule from Terraform's state file:

$ terraform state rm module.elb.aws_lb_listener_rule.blue

Finally, either comment out or delete the listener rule so that it does not affect the next terraform apply.

Procedure to Reintegrate Resources into Terraform Management

Verify the listener's ARN from the console and identify the listener rule's ARN using AWS CLI:

$ aws elbv2 describe-rules --listener-arn [listener's ARN]

The output will be as follows; copy the RuleArn:

{
    "Rules": [
        {
            "RuleArn": "arn:aws:elasticloadbalancing:ap-northeast-1:********:listener-rule/app/example-alb/********/********/********",
            "Priority": "100",
            "Conditions": [
                {
                    "Field": "host-header",
                    "Values": [
                        "dev.example.jp"
                    ],
                    "HostHeaderConfig": {
                        "Values": [
                            "dev.example.jp"
                        ]
                    }
                }
            ],

You can reintegrate the resource into Terraform management with the following command:

$ terraform import module.elb.aws_lb_listener_rule.blue [listener rule's ARN]

Conclusion

I am curious to know how others manage resources that frequently need updates like in this case.

...

✅ How to Temporarily Remove and Reintegrate Cloud Resources from Terraform Management


📈 95.94 Punkte

✅ Efficiently Deploy Cloud Resources on AWS with Terraform


📈 26.62 Punkte

✅ US federal judge issues injunction to temporarily remove Xiaomi ban


📈 25.59 Punkte

✅ Understanding Terraform: part 1 – What is Terraform?


📈 25.49 Punkte

✅ Terraform - Using GitHub Copilot Chat with Terraform


📈 25.49 Punkte

✅ Und Microsoft so: Cloud, Cloud, Cloud, Cloud, Cloud, Cloud, Cloud


📈 25.08 Punkte

✅ Understanding Explicit Dependencies between Resources or modules in Terraform


📈 23.04 Punkte

✅ Importing existing AWS IAM resources to Terraform


📈 23.04 Punkte

✅ Tagging AWS resources the right way using Terraform


📈 23.04 Punkte

✅ Deploy Terraform resources to AWS using GitHub Actions via OIDC


📈 23.04 Punkte

✅ Managing Existing AWS Resources with Terraform Import


📈 23.04 Punkte

✅ Using Terraform to Manage Resources in Multiple AWS Accounts


📈 23.04 Punkte

✅ Azure Terraform Export: Importing Resources with Aztfexport


📈 23.04 Punkte

✅ Optimizing Your Cloud Resources, Part 2: Resource Management via IBM Cloud Projects


📈 21.29 Punkte

✅ Automated user migration and management of AWS Identity and Access Management (IAM) resources


📈 21.02 Punkte

✅ MyLife and such. Is it safe to claim a page to remove it? Can I remove my family's accounts too?


📈 20.74 Punkte

✅ How to Remove PIN from Windows 11 and Fix Remove PIN Grayed Out


📈 20.74 Punkte

✅ Remote State Management with Terraform Cloud | The DevOps Lab


📈 20.16 Punkte

✅ Terraform Cloud Alternative: Cloud Infrastructure Software Compared


📈 19.91 Punkte

✅ Judge temporarily halts $10 billion Microsoft cloud contract with Pentagon


📈 19.57 Punkte

✅ Judge Temporarily Blocks Microsoft Pentagon Cloud Contract After Amazon Suit


📈 19.57 Punkte

✅ How to remove a remove apt repository from Debian


📈 19.21 Punkte

✅ How to remove a remove apt repository from Debian


📈 19.21 Punkte

✅ Remove From String in Python – How to Remove Characters from a String


📈 19.21 Punkte

✅ Remove-It 1.3.1 - Remove unwanted files when uninstalling apps.


📈 19.21 Punkte

✅ Python Remove from List – How to Remove an Item from a List in Python


📈 19.21 Punkte

✅ How to Remove Characters from a String in Arduino Using String.remove() Function


📈 19.21 Punkte

✅ Conda Remove Package - How To Remove Matplotlib in Anaconda


📈 19.21 Punkte

✅ Cloud_Enum - Multi-cloud OSINT Tool. Enumerate Public Resources In AWS, Azure, And Google Cloud


📈 18.99 Punkte

✅ Expel Unveils Threat Research and Cloud Detection, Response and Remediation Capabilities and Resources


📈 18.48 Punkte











matomo

Datei nicht gefunden!