Skip to content

Instantly share code, notes, and snippets.

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:RunTask"
],
"Resource": [
"${replace(aws_ecs_task_definition.definition.arn, "/:\\d+$/", ":*")}"
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"
resource "aws_cloudwatch_event_rule" "scheduled_task" {
name = "scheduled-ecs-event-rule"
schedule_expression = "rate(5 minutes)"
}
[
{
"name": "${definition_name}",
"image": "${image_tag}",
"cpu": 64,
"memory": 256,
"memoryReservation": 128,
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
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
FROM python:3
RUN pip install requests
WORKDIR /app
ADD index.py /app/
CMD [ "python", "/app/index.py" ]
@vthub
vthub / main.py
Last active January 4, 2020 00:28
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")
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 {
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
import React, { Component } from "react";
export default function asyncComponent(importComponent) {
class AsyncComponent extends Component {
constructor(props) {
super(props);
this.state = {
component: null
};
}
async componentDidMount() {