【问题标题】:AWS SES Runs on Local ComputerAWS SES 在本地计算机上运行
【发布时间】:2021-02-27 20:50:57
【问题描述】:

我编写了一个使用 aws ses 发送电子邮件的系统(代码如下)。这在网站上运行良好,但我也很惊讶它似乎可以在我的本地计算机上运行。我想知道的是,如果我不小心为我的 aws 帐户提供了全球发送电子邮件的能力,或者我的本地电脑是否以某种方式登录到 aws,以便它仍然可以发送电子邮件。如果是这种情况,我该如何注销以确保它是安全的?或者我如何确保它只有网站可以发送电子邮件。

谢谢

标记

# Form is valid, get the data from the form
sender_email = form.cleaned_data['form_email']

# Generate the new email message
strNewSubject = "CONTACT FROM sendemail DJANGO APP"
strNewMessage = f"Hello from a random user of sendemail Django App."

# Create a new SES resource and specify a region.   SES is in
# eu-west-1 NOT eu-west-2
client = boto3.client('ses', region_name="eu-west-1")

tmpDestination = {'ToAddresses':
                    ["blah@something.com", ], }
tmpMessage = {
        'Body': {
            'Text': {
                'Charset': "UTF-8",
                'Data': strNewMessage,
            },
        },
        'Subject': {
            'Charset': "UTF-8",
            'Data': strNewSubject,
        },
    }
# Provide the contents of the email.
response = client.send_email(
    Destination=tmpDestination,
    Message=tmpMessage,
    Source="srcaddress@gmail.com"
)

# Email sent and no error's
return True

【问题讨论】:

  • 如果您在某个时候运行 aws configure 来配置 awscli 并添加您的访问密钥,那么这就是这里所使用的。如果要从系统中删除所有已配置的访问密钥,可以删除 ~/.aws 目录。

标签: amazon-web-services amazon-ses


【解决方案1】:

这只是一些额外的点,可能会帮助将来有这种担忧的人,它扩展了 jordanm 的答案,这非常有帮助:

您可以使用以下方法获取当前可用配置文件的列表:

aws configure list-profiles

您可以使用以下方式列出您当前的个人资料:

aws configure list

您可以使用以下方式获取特定配置文件的信息:

aws configure list --profile profile_name

假设 .aws 已在您的用户目录 (~) 中设置,您可以使用以下命令查看配置和凭据文件:

cat ~/.aws/config

cat ~/.aws/credentials

然后您可以通过使用 --profile 参数或 AWS_PROFILE 环境变量来指定您正在使用的配置文件:

aws ec2 describe-volumes --profile dev
export AWS_PROFILE=dev

来源:
How to see what profile is default with CLI?
https://www.thegeekstuff.com/2019/03/aws-configure-examples/

【讨论】:

    猜你喜欢
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 2016-11-04
    • 2023-03-16
    • 2020-09-12
    • 2020-11-15
    相关资源
    最近更新 更多