Authenticate per-region for make-amis
This commit is contained in:
parent
bfc4bf99bf
commit
41f127d77b
@ -214,6 +214,8 @@ class MakeAMIs:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_args(parser):
|
def add_args(parser):
|
||||||
|
parser.add_argument("--region", "-r", default="us-west-2",
|
||||||
|
help="region to use for build")
|
||||||
parser.add_argument("profile", help="name of profile to build")
|
parser.add_argument("profile", help="name of profile to build")
|
||||||
parser.add_argument("builds", nargs="*",
|
parser.add_argument("builds", nargs="*",
|
||||||
help="name of builds within a profile to build")
|
help="name of builds within a profile to build")
|
||||||
@ -232,6 +234,7 @@ class MakeAMIs:
|
|||||||
print(f"Build dir '{build_dir}' does not exist")
|
print(f"Build dir '{build_dir}' does not exist")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
creds = IdentityBrokerClient().get_credentials(args.region)
|
||||||
out = io.StringIO()
|
out = io.StringIO()
|
||||||
|
|
||||||
res = subprocess.Popen([
|
res = subprocess.Popen([
|
||||||
@ -239,7 +242,13 @@ class MakeAMIs:
|
|||||||
"build",
|
"build",
|
||||||
f"-var-file={build_dir}/vars.json",
|
f"-var-file={build_dir}/vars.json",
|
||||||
"packer.json"
|
"packer.json"
|
||||||
], stdout=subprocess.PIPE, encoding="utf-8")
|
], stdout=subprocess.PIPE, encoding="utf-8", env={
|
||||||
|
"PATH": os.environ.get("PATH"),
|
||||||
|
"AWS_ACCESS_KEY_ID": creds["access_key"],
|
||||||
|
"AWS_SECRET_ACCESS_KEY": creds["secret_key"],
|
||||||
|
"AWS_SESSION_TOKEN": creds["session_token"],
|
||||||
|
"AWS_DEFAULT_REGION": args.region,
|
||||||
|
})
|
||||||
|
|
||||||
while res.poll() is None:
|
while res.poll() is None:
|
||||||
text = res.stdout.readline()
|
text = res.stdout.readline()
|
||||||
|
Loading…
Reference in New Issue
Block a user