我正在使用带有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) 在terraform destroy之前需要terraform apply吗?如果没有,您在更新现有基础架构时遵循的工作流程destroy是什么?如何确定是否需要?
我已经按照本教程测试Angular 2应用程序:https://angular.io/docs/ts/latest/guide/testing.html
完成该First app test部分后,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) 我的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 …