This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ecs:RunTask" | |
], | |
"Resource": [ | |
"${replace(aws_ecs_task_definition.definition.arn, "/:\\d+$/", ":*")}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_cloudwatch_event_target" "scheduled_task" { | |
target_id = "$scheduled-ecs-target" | |
rule = aws_cloudwatch_event_rule.scheduled_task.name | |
arn = aws_ecs_cluster.cluster.arn | |
role_arn = aws_iam_role.scheduled_task_cloudwatch.arn | |
ecs_target { | |
task_count = 1 | |
task_definition_arn = aws_ecs_task_definition.definition.arn | |
launch_type = "FARGATE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_cloudwatch_event_rule" "scheduled_task" { | |
name = "scheduled-ecs-event-rule" | |
schedule_expression = "rate(5 minutes)" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "${definition_name}", | |
"image": "${image_tag}", | |
"cpu": 64, | |
"memory": 256, | |
"memoryReservation": 128, | |
"essential": true, | |
"logConfiguration": { | |
"logDriver": "awslogs", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_ecs_cluster" "cluster" { | |
name = "${local.service_name}-cluster" | |
} | |
data "template_file" "definition" { | |
template = file("${path.module}/task-def/def.json") | |
vars = { | |
region = var.region | |
log_group = aws_cloudwatch_log_group.task_log_group.name | |
image_tag = data.aws_ecr_repository.ecr_repository.repository_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3 | |
RUN pip install requests | |
WORKDIR /app | |
ADD index.py /app/ | |
CMD [ "python", "/app/index.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, sys | |
print("Calling httpbin") | |
r = requests.get('https://httpbin.org/get') | |
if r.status_code != 200: | |
print("Failed") | |
sys.exit(1) | |
print("Successfully completed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import {Link, Route, HashRouter} from 'react-router-dom'; | |
import './App.css'; | |
import Public from "./Public"; | |
import asyncComponent from "./AsyncComponent"; | |
import {withAuthenticator} from 'aws-amplify-react'; | |
const AsyncProtected = asyncComponent(() => import(/* webpackChunkName: "protected/a" */ "./Protected")); | |
class App extends Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Auth} from "aws-amplify"; | |
Auth.configure({ | |
region: 'us-east-2', | |
userPoolId: '{{USER-POOL-ID}}', | |
userPoolWebClientId: '{{CLIENT-ID}}', | |
cookieStorage: { | |
domain: '{{DISTRIBUTION-ID}}.cloudfront.net', | |
path: '/', | |
expires: 5, | |
secure: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
export default function asyncComponent(importComponent) { | |
class AsyncComponent extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
component: null | |
}; | |
} | |
async componentDidMount() { |
NewerOlder