github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/helper/terraform/deploy_artifact.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/otto/app" 7 "github.com/hashicorp/otto/directory" 8 ) 9 10 // DeployArtifactExtractor is the function type that is used to 11 // extract artifacts from a Build for deploys. 12 type DeployArtifactExtractor func( 13 *app.Context, *directory.Build, *directory.Infra) (map[string]string, error) 14 15 var deployArtifactExtractors = map[string]DeployArtifactExtractor{ 16 "aws": deployArtifactExtractAWS, 17 } 18 19 func deployArtifactExtractAWS( 20 ctx *app.Context, 21 build *directory.Build, 22 infra *directory.Infra) (map[string]string, error) { 23 ami, ok := build.Artifact[infra.Outputs["region"]] 24 if !ok { 25 return nil, fmt.Errorf( 26 "An artifact for the region '%s' could not be found. Please run\n"+ 27 "`otto build` and try again.", 28 infra.Outputs["region"]) 29 } 30 31 return map[string]string{"ami": ami}, nil 32 }