diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 0c70c4d..6a69cac 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -20,26 +20,11 @@ jobs: with: python-version: 3.9 - uses: pre-commit/action@v3.0.0 - jinja-lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Install jinja libraries - run: | - python -m pip install --upgrade jinja2==3.0.1 - - name: Install jinja linter tool - run: git clone --single-branch https://github.com/drm/jinja2-lint.git /tmp/jinja2-lint && pushd /tmp/jinja2-lint && git checkout 75dcd5a - - name: Execute jinja linter - run: find . -type f -name "*.j2" -exec /tmp/jinja2-lint/j2lint.py '{}' + deploy: name: Upload to Amazon S3 runs-on: ubuntu-latest if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} - needs: [ "pre-commit", "jinja-lint" ] + needs: [ "pre-commit" ] permissions: id-token: write contents: read diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 99e61c8..d30f987 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,3 +18,8 @@ repos: rev: v1.5.4 hooks: - id: remove-tabs +- repo: https://github.com/aristanetworks/j2lint.git + rev: v1.1.0 + hooks: + - id: j2lint + args: [--ignore, V1, --] diff --git a/templates/EC2/basic-ec2.j2 b/templates/EC2/basic-ec2.j2 index d711ea1..f1de7b6 100644 --- a/templates/EC2/basic-ec2.j2 +++ b/templates/EC2/basic-ec2.j2 @@ -48,12 +48,12 @@ Resources: GroupDescription: "Allow ports for incoming traffic" VpcId: !Ref VpcId SecurityGroupIngress: - {% for port in sceptre_user_data.OpenPorts %} +{% for port in sceptre_user_data.OpenPorts %} - CidrIp: "0.0.0.0/0" FromPort: {{ port }} ToPort: {{ port }} IpProtocol: tcp - {% endfor %} +{% endfor %} {% endif %} Instance: Type: 'AWS::EC2::Instance' diff --git a/templates/EC2/jc-ec2-linux.j2 b/templates/EC2/jc-ec2-linux.j2 index 26518b2..731a746 100644 --- a/templates/EC2/jc-ec2-linux.j2 +++ b/templates/EC2/jc-ec2-linux.j2 @@ -114,12 +114,12 @@ Resources: VpcId: !ImportValue 'Fn::Sub': '${AWS::Region}-${VpcName}-VPCId' SecurityGroupIngress: - {% for port in sceptre_user_data.OpenPorts %} +{% for port in sceptre_user_data.OpenPorts %} - CidrIp: "0.0.0.0/0" FromPort: {{ port }} ToPort: {{ port }} IpProtocol: tcp - {% endfor %} +{% endfor %} SecurityGroupEgress: - CidrIp: "0.0.0.0/0" FromPort: -1 diff --git a/templates/EC2/jc-ec2-win.j2 b/templates/EC2/jc-ec2-win.j2 index 8946e44..4ba5f45 100644 --- a/templates/EC2/jc-ec2-win.j2 +++ b/templates/EC2/jc-ec2-win.j2 @@ -114,12 +114,12 @@ Resources: VpcId: !ImportValue 'Fn::Sub': '${AWS::Region}-${VpcName}-VPCId' SecurityGroupIngress: - {% for port in sceptre_user_data.OpenPorts %} +{% for port in sceptre_user_data.OpenPorts %} - CidrIp: "0.0.0.0/0" FromPort: {{ port }} ToPort: {{ port }} IpProtocol: tcp - {% endfor %} +{% endfor %} SecurityGroupEgress: - CidrIp: "0.0.0.0/0" FromPort: -1 diff --git a/templates/IAM/github-oidc-provider.j2 b/templates/IAM/github-oidc-provider.j2 index b7b8b4e..15654bf 100644 --- a/templates/IAM/github-oidc-provider.j2 +++ b/templates/IAM/github-oidc-provider.j2 @@ -12,10 +12,10 @@ {# GitHubOrg: "Sage-Bionetworks" #} {% if sceptre_user_data.Repositories is defined %} - {% set Repositories = sceptre_user_data.Repositories %} +{% set Repositories = sceptre_user_data.Repositories %} {% endif %} {% if sceptre_user_data.GitHubOrg is defined %} - {% set GitHubOrg = sceptre_user_data.GitHubOrg %} +{% set GitHubOrg = sceptre_user_data.GitHubOrg %} {% endif %} AWSTemplateFormatVersion: 2010-09-09 @@ -104,13 +104,13 @@ Resources: StringLike: token.actions.githubusercontent.com:sub: [ {% for Repository in Repositories %} - {% for branch in Repository.branches %} - {% if branch == '*' %} - "repo:{{ GitHubOrg}}/{{ Repository.name }}:{{ branch }}", - {% else %} - "repo:{{ GitHubOrg}}/{{ Repository.name }}:ref:refs/heads/{{ branch }}", - {% endif %} -{% endfor %} +{% for branch in Repository.branches %} +{% if branch == '*' %} + "repo:{{ GitHubOrg }}/{{ Repository.name }}:{{ branch }}", +{% else %} + "repo:{{ GitHubOrg }}/{{ Repository.name }}:ref:refs/heads/{{ branch }}", +{% endif %} +{% endfor %} "repo:{{ GitHubOrg }}/{{ Repository.name }}:ref:refs/tags/*", "repo:{{ GitHubOrg }}/{{ Repository.name }}:environment:*", {% endfor %} diff --git a/templates/S3/synapse-external-bucket.j2 b/templates/S3/synapse-external-bucket.j2 index 7919a87..f09823c 100644 --- a/templates/S3/synapse-external-bucket.j2 +++ b/templates/S3/synapse-external-bucket.j2 @@ -172,9 +172,9 @@ Resources: Key: owner.txt ContentType: text Body: >- - {% for SynapseID in sceptre_user_data.SynapseIDs %} + {% for SynapseID in sceptre_user_data.SynapseIDs %} {{ SynapseID }} - {% endfor %} + {% endfor %} {% endif %} IPAddressRestictionLambda: diff --git a/templates/SystemsManager/ssm-parameters.j2 b/templates/SystemsManager/ssm-parameters.j2 index 1ec9f88..e75d531 100644 --- a/templates/SystemsManager/ssm-parameters.j2 +++ b/templates/SystemsManager/ssm-parameters.j2 @@ -9,7 +9,7 @@ template_path: remote/ssm-parameters.j2 hooks: before_launch: - - !cmd "curl https://{{stack_group_config.admincentral_cf_bucket}}.s3.amazonaws.com/aws-infra/master/ssm-parameters.j2 --create-dirs -o templates/remote/ssm-parameters.j2" + - !cmd "curl https://{{ stack_group_config.admincentral_cf_bucket }}.s3.amazonaws.com/aws-infra/master/ssm-parameters.j2 --create-dirs -o templates/remote/ssm-parameters.j2" stack_name: my-ssm-vars sceptre_user_data: Prefix: /my-ssm-vars/ @@ -24,8 +24,8 @@ Description: "Setup parameters in the SSM parameter store" AWSTemplateFormatVersion: "2010-09-09" Resources: {% for parameter in sceptre_user_data.Parameters %} - {%- set name = parameter.Name -%} - {%- set value = parameter.Value|safe -%} + {% set name = parameter.Name %} + {% set value = parameter.Value | safe %} {{ name }}: Type: AWS::SSM::Parameter Properties: @@ -39,8 +39,8 @@ Outputs: Export: Name: !Sub '${AWS::Region}-${AWS::StackName}-Prefix' {% for parameter in sceptre_user_data.Parameters %} - {%- set name = parameter.Name -%} - {%- set value = parameter.Value -%} + {% set name = parameter.Name %} + {% set value = parameter.Value %} {{ name }}: Value: !GetAtt {{ name }}.Value Export: