Skip to content

Commit

Permalink
Merge pull request #181 from stefanjenkner/177-cloudformation-errors
Browse files Browse the repository at this point in the history
fix: CloudFormation errors #177
  • Loading branch information
stefanjenkner authored Apr 21, 2024
2 parents fdbf61a + 7bdf72c commit 67f1b3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ Current features:
* VPC with public subnet and security groups to restrict access by IP
* S3 bucket for fast backup/restore of your Steam Library to/from instance storage using [restic]

## Howto
## How-to

Show template:

./deploy.py --print-only

Create or update stack:
Deploying the CloudFormation stack the first time requires a keypair (in this case `ec2-gaming`) to exist:

./deploy.py --keypair ec2-gaming

When updating CloudFormation stack, passing parameters is not required and existing settings remain untouched:

./deploy.py

Expand All @@ -29,7 +33,7 @@ Launch on-demand instance:

aws ec2 run-instances --launch-template LaunchTemplateName=jammy-sunshine-on-demand,Version=\$Latest

Update IP address in security groups:
By default, access to the EC2 instance is restriced. To update ane set the whitelisted IP address to the IP address of the caller:

./update-ip.py

Expand Down Expand Up @@ -90,4 +94,4 @@ Add apps for different screen resolutions:
[Sunshine]: https://github.com/LizardByte/Sunshine/
[cloud-init]: https://cloudinit.readthedocs.io/
[restic]: https://github.com/restic/restic/
[Moonlight]: https://github.com/moonlight-stream/moonlight-qt/
[Moonlight]: https://github.com/moonlight-stream/moonlight-qt/
9 changes: 6 additions & 3 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
from jinja2 import Template

STACK_NAME = "jammy-sunshine"
DEFAULT_KEYPAIR = "ec2-gaming"
INITIAL_WHITELISTED_IP = "127.0.0.1/32"


def main():

parser = argparse.ArgumentParser(prog="deploy", epilog="Create or update stack")
parser.add_argument("--print-only", action="store_true")
parser.add_argument("--print-only", help="Print CF template but do not deploy", action="store_true")
parser.add_argument("--keypair", help=f"Name of EC2 keypair to use, defaults to '{DEFAULT_KEYPAIR}'", default=DEFAULT_KEYPAIR)

args = parser.parse_args()

Expand Down Expand Up @@ -74,8 +77,8 @@ def main():
StackName=STACK_NAME,
TemplateBody=template.render(cloud_config=cloud_config_b64_text_),
Parameters=[
{"ParameterKey": "MyIp", "ParameterValue": "127.0.0.1"},
{"ParameterKey": "KeyPair", "ParameterValue": "ec2-gaming"},
{"ParameterKey": "MyIp", "ParameterValue": INITIAL_WHITELISTED_IP},
{"ParameterKey": "KeyPair", "ParameterValue": args.keypair},
],
Capabilities=["CAPABILITY_NAMED_IAM"],
)
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.ruff]
[tool.ruff.lint]
ignore = ["E501"]

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
inline-quotes = "double"
multiline-quotes = "double"
docstring-quotes = "double"

[tool.ruff.mccabe]
max-complexity = 7
[tool.ruff.lint.mccabe]
max-complexity = 7

0 comments on commit 67f1b3c

Please sign in to comment.