AWS

De Wiki Doth
Revisão de 22h06min de 23 de fevereiro de 2024 por Murilo (discussão | contribs) (→‎S3)
Ir para navegação Ir para pesquisar


EC2

Metadatas: http://169.25.169.254/latest/metadata

https://docs.aws.amazon.com/pt_br/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

Code Deploy

Instalar agente do CodeDeploy

sudo apt-get update

sudo apt install ruby-full

sudo apt install wget

cd /home/user/

wget https://bucket-name.s3.region-identifier.amazonaws.com/latest/install

wget https://aws-codedeploy-sa-east-1.s3.sa-east-1.amazonaws.com/latest/install

chmod +x ./install

sudo ./install auto

https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-ubuntu.html

  • Verificar

sudo service codedeploy-agent status

sudo service codedeploy-agent start

Erro Code Deploy

The ApplicationStop hook is being called from the previously installed deployment before trying to run the current deployment appspec.yml file.

In order to prevent this from happening you'll have to remove any previously installed deployment from the server.

Stop the code deploy agent

sudo service codedeploy-agent stop

clear all deployments under

/opt/codedeploy-agent/deployment-root

Restart the code deploy agent

sudo service codedeploy-agent start

S3

Comandos uteis

lista os arquivos / tamanho

aws s3 ls s3://bucket/x --recursive --human-readable --summarize


Bucket site externo

  • criar bucket (nome do bucket tem que ser a url)
  • ativar hospedagem de site (redirecionamento p/objeto - index.html)
  • colocar política base do bucket

{

   "Version": "2012-10-17",
   "Statement": [
       {
           "Sid": "PublicReadGetObject",
           "Effect": "Allow",
           "Principal": "*",
           "Action": "s3:GetObject",
           "Resource": "arn:aws:s3:::endereco.site.com.br/*"
       }       
   ]

}


  • criar distribuição no cloudfront
    • Default root object: index.html
  • solicitar certificado pelo cloudfront

SES

Sistema de envio de e-mails

SES Template

aws ses create-template --generate-cli-skeleton > arquivo.json (gera um arquivo padrão)

aws ses create-template --cli-input-json file://file.json

aws ses detele-template --template-name MyTemplate

aws ses get-template --template-name MyTemplate

aws ses update-template --cli-input-json file://file.json

aws ses test-render-template --template-name MyTemplate --template-data {"nome":"nome_do_template"} --region sa-east-1

Envio em massa

  • Criar SQS fifo
  • Criar função lambda: atenção as permissões (SES,SQS)
  • Ligar fila SQS a função lambda
  • Enviar para a fila

Envio:

{"sendTo":"destino@provedor.com","TemplateData":"{\"var1\":\"valor1\",\"var2\":\"valor2\"}","Source":"no-reply@dominio.com.br","Template":"nomedoTemplate"}

SQS

Simple Queue Service - distribuição de mensagens da aplicação

Códigos em produção

Whatsapp

unica: dothSendWhatsApp

multiplas: dothSendWhatsApp.fifo

conteudo:

{"from":"aplicacao","to":"destino","mensagem":"o conteudo da mensagem"}

Destino: Lambda - dothSendWhatsApp