Application Security on AWS: ACM, CloudFront Signed URLs, WAF, Cognito Protection and Securing AI Applications

AWS Developer Associate 50 min min read Updated: Nov 17, 2026 Advanced
Application Security on AWS: ACM, CloudFront Signed URLs, WAF, Cognito Protection and Securing AI Applications
Advanced Topic 3 of 3

Defense in Depth for Apps

text Users ─► Route 53 ─► CloudFront (TLS, caching, signed URLs) ─► AWS WAF (OWASP rules, rate limits, bot control) ─► ALB / API Gateway (auth, throttling) ─► app code (validation, least privilege role) ─► data stores (KMS encryption, private subnets, security groups)

TLS with AWS Certificate Manager (ACM)

  • ACM issues free public certificates for use with CloudFront, ALB, NLB, API Gateway, AppSync and renews them automatically when validated by DNS (a CNAME record, easy in Route 53)
  • Certificates for **CloudFront and Cognito custom domains must be in us-east-1. For ALB and API Gateway regional endpoints request them in the same Region**
  • You cannot export public certificates to install on your own servers (use ACM Private CA or an external CA for that)
  • Enforce HTTPS: ALB redirect 80 to 443, CloudFront viewer protocol policy: redirect HTTP to HTTPS, aws:SecureTransport in bucket policies, TLS 1.2 or higher

Protecting Private Content with CloudFront

GoalTool
Only CloudFront can read the S3 bucketOrigin Access Control (OAC) (replaces older OAI) plus a bucket policy allowing the distribution
Only CloudFront can reach your ALBSecret custom header check, or the CloudFront managed prefix list in the ALB security group, or VPC origins
Paid or private downloads for specific usersSigned URLs (one file) or signed cookies (many files)
Block countriesGeo restriction
Control cache and headers safelyCache policies, origin request policies, response headers policies (HSTS, CSP)
Signed URLSigned cookie
One file or an RTMP-style single URLMany files (a whole site area, HLS video segments)
URL changesURLs stay the same
  • Signing uses a CloudFront key group (public key in CloudFront, private key in your backend). Keep the private key in Secrets Manager
  • Do not confuse with S3 presigned URLs, which sign for S3 directly with IAM credentials. Use CloudFront signed URLs when content is delivered through CloudFront
python from botocore.signers import CloudFrontSigner from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import padding import datetime def rsa_signer(message): key = serialization.load_pem_private_key(PRIVATE_KEY_PEM, password=None) return key.sign(message, padding.PKCS1v15(), hashes.SHA1()) # CloudFront canned policy uses RSA-SHA1 signer = CloudFrontSigner("K2JCJMDEHXQW5F", rsa_signer) # public key id url = signer.generate_presigned_url("https://dxxxx.cloudfront.net/videos/lesson1.mp4", date_less_than=datetime.datetime.utcnow() + datetime.timedelta(minutes=10))

AWS WAF

  • WAF inspects HTTP(S) requests on CloudFront, ALB, API Gateway REST, AppSync, Cognito, App Runner, Verified Access
  • A web ACL has rules evaluated in priority order. Actions: Allow, Block, Count, CAPTCHA, Challenge
  • AWS managed rule groups: Core rule set (OWASP-style), SQL injection, known bad inputs, IP reputation, anonymous IP list, bot control, account takeover protection
  • Rate-based rules block an IP that sends more than N requests in 5 minutes (stops brute force and scraping)
  • Start rules in Count mode, watch logs, then switch to Block. Send WAF logs to S3, CloudWatch Logs or Firehose
  • Shield Standard protects against common network and transport DDoS automatically and free. Shield Advanced adds more protection, response team and cost protection
json { "Name": "rate-limit-login", "Priority": 10, "Statement": {"RateBasedStatement": {"Limit": 100, "AggregateKeyType": "IP", "ScopeDownStatement": {"ByteMatchStatement": {"SearchString": "/login", "FieldToMatch": {"UriPath": {}}, "TextTransformations": [{"Priority": 0, "Type": "NONE"}], "PositionalConstraint": "STARTS_WITH"}}}}, "Action": {"Block": {}}, "VisibilityConfig": {"SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "rate-limit-login"} }

Secure Coding Checklist for AWS Apps

  • Validate and encode all input and output. Use parameterized queries. Avoid eval and shell injection
  • Protect against SSRF: do not fetch user-supplied URLs from servers with IAM roles unless filtered. Use IMDSv2
  • Least-privilege roles per function and per service. No wildcards on sensitive actions
  • Encrypt at rest and in transit. Keep secrets out of logs
  • Keep dependencies patched (Amazon Inspector scans EC2, ECR and Lambda). Use CodeGuru Security or other scanners in CI
  • Use short-lived credentials, MFA and OIDC federation for CI/CD instead of stored keys
  • Log with CloudTrail, CloudWatch, GuardDuty to detect misuse

Securing AI Applications (Amazon Bedrock and Agents)

Applications that use foundation models bring new risks. The same principles apply (access control, privacy, logging) plus AI-specific controls.

RiskDefense
Unauthorized model or data accessIAM least privilege for bedrock:InvokeModel on specific model ARNs, VPC endpoints (PrivateLink) for private traffic, resource-based and Region/model allow lists in SCPs
Sensitive data exposureDo not send secrets or unnecessary personal data in prompts. Mask or redact PII. Bedrock Guardrails can detect and block or mask PII. Encrypt with KMS and control retention
Unsafe or harmful contentGuardrails: content filters, denied topics, word filters, grounding checks, applied to inputs and outputs
Prompt injection (user or retrieved documents try to override instructions)Treat model input as untrusted. Keep system instructions separate, filter and validate outputs, use Guardrails prompt-attack filter, never let model text directly run commands or SQL, limit what the model can do
Excessive agent permissionsGive each agent tool its own least-privilege role. Require human approval for risky actions (payments, deletes). Validate tool arguments with a schema. Log every tool call
Secrets and personal data in logsTurn model invocation logging on only with care, do not log full prompts containing sensitive data, restrict log access, set retention, redact before logging
Poisoned or leaky knowledge basesControl who can add documents, use metadata filtering and per-user access checks at retrieval time
Cost abuse and denial of walletAuthenticate users, rate limit with WAF and API throttling, set token limits and budgets, alarms on usage
python import boto3 br = boto3.client("bedrock-runtime", region_name="us-east-1") resp = br.converse( modelId="anthropic.claude-sonnet-4-5-20250929-v1:0", # use a model id available to you messages=[{"role": "user", "content": [{"text": user_text}]}], guardrailConfig={"guardrailIdentifier": "gr-abc123", "guardrailVersion": "1", "trace": "enabled"}, inferenceConfig={"maxTokens": 500, "temperature": 0.2}, ) print(resp["output"]["message"]["content"][0]["text"]) print(resp["stopReason"]) # 'guardrail_intervened' when blocked
Model IDs change Model identifiers and availability by Region change often. Look up the current model ID in the Bedrock console or API (list-foundation-models) instead of copying an old one.

Practice Tasks

  1. Request an ACM certificate with DNS validation and attach it to an ALB HTTPS listener
  2. Put a private S3 bucket behind CloudFront with OAC and confirm the direct S3 URL is blocked
  3. Generate a CloudFront signed URL that expires in 10 minutes
  4. Add a WAF web ACL with the Core rule set and a rate-based rule in Count mode, then Block
  5. Create a Bedrock guardrail that masks email addresses and blocks a denied topic, and test it

Conclusion

Layer your defenses: ACM for TLS, CloudFront with OAC and signed URLs for private content, WAF managed and rate rules, least-privilege roles, input validation and secret hygiene. For AI features add IAM scoping of models, Guardrails, prompt-injection awareness, limited and approved agent tools, and careful logging of sensitive data.

Quick Summary: layers; ACM; CloudFront protection; WAF; secure coding; AI security risks and defenses; Bedrock guardrails example.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators