Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

[breaking] Use fixed filepath to prevent spurious diffs #12

Merged
merged 2 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pkg/provider/data_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ func Lambda() *schema.Resource {
Description: "The kmsauth key ID",
ForceNew: true,
},

// computed
SchemaOutputPath: &schema.Schema{
Type: schema.TypeString,
Computed: true,
Required: true,
Description: "Temporary directory that holds the bless zip",
ForceNew: true,
},

// computed
SchemaOutputBase64Sha256: &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -146,9 +147,10 @@ func (l *resourceLambda) getBlessConfig(d *schema.ResourceData) (io.Reader, os.F

// Create bundles the lambda code and configuration into a zip that can be uploaded to AWS lambda
func (l *resourceLambda) Read(d *schema.ResourceData, meta interface{}) error {
outFile, err := ioutil.TempFile("", "bless.zip")
path:= d.Get(SchemaOutputPath).(string)
outFile, err := os.Create(path)
if err != nil {
return errors.Wrap(err, "Could not open temporary file")
return errors.Wrapf(err, "Could not open output file at %s", path)
}
defer outFile.Close()
writer := zip.NewWriter(outFile)
Expand All @@ -168,7 +170,6 @@ func (l *resourceLambda) Read(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return err
}

// Write the config
err = l.writeFileToZip(blessConfig, blessConfigFileInfo, writer, "bless_deploy.cfg")
if err != nil {
Expand All @@ -181,7 +182,6 @@ func (l *resourceLambda) Read(d *schema.ResourceData, meta interface{}) error {
return err
}

d.Set(SchemaOutputPath, outFile.Name())
d.Set(SchemaOutputBase64Sha256, fileHash)
d.SetId(fileHash)
return err
Expand Down
9 changes: 2 additions & 7 deletions pkg/provider/data_lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,19 @@ func TestLambdaCreate(t *testing.T) {
encrypted_password = "bbbb"
service_name = "test"
kmsauth_key_id = "keyID"

}

output "output_path" {
value = "${data.bless_lambda.zip.output_path}"
output_path = "/tmp/test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"/tmp/test.zip" since it's an actual file now?

}

output "output_base64sha256" {
value = "${data.bless_lambda.zip.output_base64sha256}"
}
`,
Check: func(s *terraform.State) error {
outputPath := s.RootModule().Outputs[provider.SchemaOutputPath].Value
base64sha256 := s.RootModule().Outputs[provider.SchemaOutputBase64Sha256].Value
a.NotEmpty(outputPath)
a.NotEmpty(base64sha256)
return nil
},
Destroy: true,
},
},
})
Expand Down