向gitlab管道添加逻辑,以使用terraform部署AWS或Azure资源

unguejic  于 2023-05-29  发布在  Git
关注(0)|答案(1)|浏览(118)

我有一个从DynamoDB表中提取数据的管道。根据引入的变量,我希望它运行一个创建Azure或AWS资源的管道。这可能吗?最好的方法是什么?如果你有进一步阅读的资源,我将不胜感激!
我正在进行研究,并试图提出可能的解决方案,为上游管道增加逻辑。

hmae6n7t

hmae6n7t1#

您需要使用一列来对数据库数据进行排序,该列将标识AWS/Azure数据。
1.在GitLab中创建一个Terraform provider.tf文件,其中包含两个提供商AWS和Azurerm

Provider.tf文件

provider "aws" {
    features{}
    metadata_host= "AWS https url connection"
    Clientcreadentials = ""
    etc
    etc
}

provider "azurerm" {
    features{}
    metadata_host= "AWS https url connection"
    Clientcreadentials = ""
    etc
    etc
}

1.创建main.tf文件

Main.tf

# See [Terraform AWS Resources documentation][1]
resource "aws_resourcegroups_group" "example" {
    provider = aws
    name = dynamotable.AWS.name
}

# See [Terraform Azure Resources documentation][2]
resource "azurerm_resource_group" "example" {
    provider = azurerm
    name = dynamotable.Azurerm.name
}

  [1]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/resourcegroups_group
  [2]: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group

相关问题