小编fip*_*ips的帖子

如何自动将打包器输出ami id链接到terraform变量?

我正在使用带有ansible配置器的打包器来构建一个ami,并使用这个ami作为源来设置基础设施 - 与本文有点类似:http://www.paulstack.co.uk/blog/2016/01/ 02 /建筑物-AN-elasticsearch群集式-AWS与-封隔器和terraform

当命令packer build pack.json成功完成时,我以这种格式获得输出ami id:

eu-central-1: ami-12345678
Run Code Online (Sandbox Code Playgroud)

在我的terraform变量中,variables.tf我需要指定源ami id,region等.这里的问题是我不想手动或多次指定它们.对于区域(我事先知道),因为我可以在两种情况下使用环境变量,所以很容易,但是输出ami呢?是否有内置的方式来链接这些产品或一些不那么hacky方法来做到这一点?

编辑: Hacky方法适用于任何可能感兴趣的人.在这个解决方案中,我是grep来自packer输出的aws region&ami,并在perl中使用正则表达式将结果写入terraform.tfvars文件:

vars=$(pwd)"/terraform.tfvars"
packer build pack.json | \
    tee /dev/tty | \
    grep -E -o '\w{2}-\w+-\w{1}: ami-\w+' | \
    perl -ne '@parts = split /[:,\s]+/, $_; print "aws_amis." . $parts[0] ." = \"" . $parts[1] . "\"\n"' > ${vars}
Run Code Online (Sandbox Code Playgroud)

bash packer amazon-web-services terraform

18
推荐指数
2
解决办法
5621
查看次数

在使用terraform之前需要进行地形破坏吗?

在terraform destroy之前需要terraform apply吗?如果没有,您在更新现有基础架构时遵循的工作流程destroy是什么?如何确定是否需要?

terraform

9
推荐指数
3
解决办法
6460
查看次数

用于TypeScript应用程序测试的Angular 2 - 规格在茉莉花中多次出现

我已经按照本教程测试Angular 2应用程序:https://angular.io/docs/ts/latest/guide/testing.html

完成该First app test部分后,unit-tests.html我看到我的规范报告多次出现:

jasmine unit-tests.html
虽然我没有对教程代码进行任何更改,但是为了快速参考,我的unit-tests.html是:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>Ng App Unit Tests</title>

    <link rel="stylesheet" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css">

    <script src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
    <script src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
    <script src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
</head>
<body>
<!-- #1. add the system.js library -->
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>

<script>
    // #2. Configure systemjs to use the .js extension
    //     for imports from the app folder
    System.config({
        packages: {
            'app': {defaultExtension: 'js'}
        }
    });

    // #3. Import the spec file explicitly
    System.import('app/hero.spec')

    // …
Run Code Online (Sandbox Code Playgroud)

jasmine typescript systemjs angular

5
推荐指数
1
解决办法
1729
查看次数

如何使用angular2中的链接参数数组从子组件导航到上层路由?

我的AppComponent有一个@RouteConfig装饰器,用于定义顶级路径:

@RouteConfig([
  {
    path: '/',
    name: 'Home',
    component: HomeComponent
  },
  {
    path: '/about',
    name: 'About',
    component: AboutComponent
  },
  {
    path: '/profile/...',
    name: 'Profile',
    component: ProfileComponent
  }
])

export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)

我的ProfileComponent有一个@RouteConfig装饰器,用于定义Profile子路径:

@RouteConfig([
  {path: '/', component: ProfileDetailsComponent, name: 'View', useAsDefault: true},
  {path: '/:id', component: ProfileDetailsComponent, name: 'Public'},
  {path: '/edit', component: ProfileEditorComponent, name: 'Edit'},
])

export class ProfileComponent {
}
Run Code Online (Sandbox Code Playgroud)

当我在ProfileDetailsComponent中时,我可以重定向到其他Profile路由但不能重定向到其他路由.我想避免使用navigateByUrl和使用路由名称来指定URL navigate.例如:

this.router.navigate(['View']); // Works
this.router.navigate(['About']); // Raises error that it does not exist
Run Code Online (Sandbox Code Playgroud)

我在这里读到这个答案:Angular 2 …

typescript angular2-routing angular

5
推荐指数
2
解决办法
1393
查看次数