terraform-for循环的副本-全局表的区域名称

时间:2018-09-10 22:13:55

标签: amazon-web-services amazon-dynamodb terraform terraform-provider-aws

我正在使用具有多区域复制的地形创建aws全局表。

use setasign\Fpdi\Fpdi;
require('fpdf181/fpdf.php');
require('fpdi/autoload.php');

function split_pdf($filename, $end_directory = false)
{

    $end_directory = $end_directory ? $end_directory : './';
    $new_path = preg_replace('/[\/]+/', '/', $end_directory.'/'.substr($filename, 0, strrpos($filename, '/')));

    if (!is_dir($new_path))
    {
        // Will make directories under end directory that don't exist
        // Provided that end directory exists and has the right permissions
        mkdir($new_path, 0777, true);
    }

    $pdf = new FPDI();
    $pagecount = $pdf->setSourceFile($filename); // How many pages?

    // Split each page into a new PDF
    for ($i = 1; $i <= $pagecount; $i++) {
        $new_pdf = new FPDI();
        $new_pdf->AddPage();
        $new_pdf->setSourceFile($filename);
        $templateIndex = $new_pdf->importPage($i);
        $new_pdf->useTemplate($templateIndex, null, null, 0, 0, true);

        try {
            $new_filename = $end_directory.str_replace('.pdf', '', $filename).'_'.$i.".pdf";
            $new_pdf->Output($new_filename, "F");
            echo "Page ".$i." split into ".$new_filename."<br />\n";
        } catch (Exception $e) {
            echo 'Caught exception: ',  $e->getMessage(), "\n";
        }
    }
}
// Create and check permissions on end directory!
split_pdf("contract.pdf", 'split/');

接下来,我将使用 resource "aws_dynamodb_global_table" "test_table" { depends_on = ["aws_dynamodb_table.us-east-1", "aws_dynamodb_table.us-west-2"] provider = "aws.us-east-1" name = "test" replica { region_name = "us-east-1" } replica { region_name = "us-west-2" } } count将两个区域表都创建为模块,并为每个表返回ARN。

如何创建全局表作为模块,在其中添加对两个表的引用? interpolationdepends_on在这种情况下。

已通过尝试的方法进行了更新:

replica

我正在下面传递给全局表

//Templ1 
{ region_name = "${region_name}" }

//Templ2
  ${value} 

data "template_file" "replica_region" {
  template = "${file("${path.module}/replica-region.json.tmpl")}" 
  count = "${length(var.regions)}"
  vars {
    region_name = "${element(var.regions, count.index)}"
  }
}

data "template_file" "replica_regional" {
  template = "${file("${path.module}/replica-regional.json.tmpl")}" 
  vars {
    value = "${join(",", data.template_file.replica_region.*.rendered)}"
  }
}

但是出现错误replica = [ "${data.template_file.replica_regional.rendered}" ] ,就像我为replica.0.region_name : required field is not set进行输出时,我得到的输出低于输出。

"${data.template_file.replica_regional.rendered}"

如果我在terraform配方上面进行硬编码就可以了。我想念什么?我指的是本文Link

0 个答案:

没有答案