Skip to content

Commit

Permalink
json stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuss committed Apr 6, 2022
1 parent 7a7f959 commit b5704f2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/services/StateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class StateService {
Key: `${identity.ownerId}/${identity.repoId}/${identity.workspace}.tfstate`,
ServerSideEncryption: 'aws:kms',
SSEKMSKeyId: env['key-id'],
Body: state,
Body: JSON.stringify(state),
})
.promise();

Expand Down Expand Up @@ -98,7 +98,13 @@ export class StateService {

const download = await s3.getObject({ Bucket: s3Meta.bucket, Key: s3Meta.key }).promise();

return download.Body;
const { Body } = download;

if (!Body) {
return null;
}

return JSON.parse(Body.toString());
};

public lockState = async (
Expand Down

0 comments on commit b5704f2

Please sign in to comment.