Skip to content

Commit

Permalink
Include file hash in the resource state for the Python provisioner ex…
Browse files Browse the repository at this point in the history
…ample (pulumi#864)
  • Loading branch information
Lee Zen authored Jan 7, 2021
1 parent 6ab1398 commit 695da88
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aws-py-ec2-provisioners/provisioners.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
from typing import Any, Optional
from typing_extensions import TypedDict
from uuid import uuid4
import hashlib


def sha256sum(filename):
h = hashlib.sha256()
with open(filename, 'rb') as f:
data = f.read()
h.update(data)
return h.hexdigest()

# ConnectionArgs tells a provisioner how to access a remote resource. It includes the hostname
# and optional port (default is 22), username, password, and private key information.
Expand Down Expand Up @@ -115,6 +124,7 @@ def __init__(self, name: str, conn: pulumi.Input[ConnectionArgs],
'conn': conn,
'src': src,
'dest': dest,
'fileHash': sha256sum(src),
},
opts,
)
Expand Down

0 comments on commit 695da88

Please sign in to comment.