Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CloudFormation errors #177 #181

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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